Skip to content

Commit

Permalink
Merge pull request #41 from minos-framework/issue-37-automatic-dbs-cr…
Browse files Browse the repository at this point in the history
…eation

#37 - Automatic dbs creation
  • Loading branch information
albamig authored Mar 9, 2022
2 parents 88127ee + 89a9390 commit f2504c2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 24 deletions.
8 changes: 8 additions & 0 deletions microservice/language/python/init/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ def build_deploy_playbook(path: Path) -> str:
def build_docker_compose(path: Path, microservice_name: str) -> str:
"""Build Docker Compose file content."""

db_creation_path = path.parent / "external/postgres/10-create-database.sql"
if not db_creation_path.exists():
raise ValueError("external/postgres/10-create-database.sql script must exist")

with db_creation_path.open("a") as db_creation_file:
db_creation_file.write(f"\nCREATE DATABASE {microservice_name}_db;")
db_creation_file.write(f"\nCREATE DATABASE {microservice_name}_query_db;")

if not path.exists():
raise ValueError("A base Compose file must exist.")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- Create microservices databases
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM postgres
COPY create-multiple-postgresql-databases.sh /docker-entrypoint-initdb.d/
FROM postgres:14.2
COPY init/10-create-database.sql /docker-entrypoint-initdb.d/10-create-database.sql

This file was deleted.

0 comments on commit f2504c2

Please sign in to comment.