fix(alembic): use db URL resolver so migrations use same DB as app
This commit is contained in:
parent
07288a01d7
commit
eef23cd952
1 changed files with 3 additions and 4 deletions
|
|
@ -4,16 +4,15 @@ from logging.config import fileConfig
|
||||||
from sqlalchemy import engine_from_config, pool
|
from sqlalchemy import engine_from_config, pool
|
||||||
|
|
||||||
from alembic import context
|
from alembic import context
|
||||||
from db import Base
|
from db import Base, _resolve_database_url
|
||||||
|
|
||||||
config = context.config
|
config = context.config
|
||||||
|
|
||||||
if config.config_file_name is not None:
|
if config.config_file_name is not None:
|
||||||
fileConfig(config.config_file_name)
|
fileConfig(config.config_file_name)
|
||||||
|
|
||||||
db_url = os.getenv("PRY_DATABASE_URL")
|
# Always use the same URL resolution logic as the application.
|
||||||
if db_url is not None:
|
config.set_main_option("sqlalchemy.url", os.getenv("PRY_DATABASE_URL") or _resolve_database_url())
|
||||||
config.set_main_option("sqlalchemy.url", db_url)
|
|
||||||
|
|
||||||
target_metadata = Base.metadata
|
target_metadata = Base.metadata
|
||||||
exclude_tables = {"spatial_ref_sys"}
|
exclude_tables = {"spatial_ref_sys"}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue