Skip to content

Commit 4450fb2

Browse files
committed
Alembic now using password from environment
1 parent 85580f2 commit 4450fb2

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/server/alembic.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ script_location = alembic
3636
# output_encoding = utf-8
3737

3838
# Container
39-
sqlalchemy.url = postgresql://postgres:thispasswordisverysecure@paws-compose-db/paws
39+
sqlalchemy.url = postgresql://postgres:PASSWORD@paws-compose-db/paws
4040

4141
# Local
4242
# sqlalchemy.url = postgresql://postgres:thispasswordisverysecure@localhost/paws

src/server/alembic/env.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from sqlalchemy import engine_from_config
44
from sqlalchemy import pool
55

6+
from os import environ
7+
68
from alembic import context
79

810
# this is the Alembic Config object, which provides
@@ -25,6 +27,13 @@
2527
# ... etc.
2628

2729

30+
PG_URL1 = 'postgresql://postgres:'
31+
PG_URL2 = environ['POSTGRES_PASSWORD']
32+
PG_URL3 = '@paws-compose-db/paws'
33+
34+
PG_URL = PG_URL1 + PG_URL2 + PG_URL3
35+
36+
2837
def run_migrations_offline():
2938
"""Run migrations in 'offline' mode.
3039
@@ -37,7 +46,8 @@ def run_migrations_offline():
3746
script output.
3847
3948
"""
40-
url = config.get_main_option("sqlalchemy.url")
49+
# url = config.get_main_option("sqlalchemy.url")
50+
url = PG_URL
4151
context.configure(
4252
url=url,
4353
target_metadata=target_metadata,
@@ -60,6 +70,7 @@ def run_migrations_online():
6070
config.get_section(config.config_ini_section),
6171
prefix="sqlalchemy.",
6272
poolclass=pool.NullPool,
73+
url=PG_URL,
6374
)
6475

6576
with connectable.connect() as connection:

0 commit comments

Comments
 (0)