diff --git a/microservice/language/python/init/_utils.py b/microservice/language/python/init/_utils.py index 30a3216..4730b3d 100644 --- a/microservice/language/python/init/_utils.py +++ b/microservice/language/python/init/_utils.py @@ -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 / "external/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.") diff --git a/project/database/postgres/deploy/docker-compose/_utils.py b/project/database/postgres/deploy/docker-compose/_utils.py index 1e26618..29cda49 100644 --- a/project/database/postgres/deploy/docker-compose/_utils.py +++ b/project/database/postgres/deploy/docker-compose/_utils.py @@ -25,8 +25,8 @@ def build_docker_compose(path: Path) -> str: "build": "external/postgres", "command": "postgres -c 'max_connections=200'", "ports": ["5432"], - "volumes": ["postgres:/var/lib/postgresql/data",], - "environment": {"POSTGRES_USER": "minos", "POSTGRES_PASSWORD": "min0s",}, + "volumes": ["postgres:/var/lib/postgresql/data", ], + "environment": {"POSTGRES_USER": "minos", "POSTGRES_PASSWORD": "min0s", }, } data["services"]["postgres"] = container