Skip to content

Commit

Permalink
Fix migration env.py to check our schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
Rikuoja committed Jan 26, 2024
1 parent 5f7f804 commit 9f61e88
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions database/migrations/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ def include_object(object, name, type_, reflected, compare_to):
return True


# Check our schemas
def include_name(name, type_, parent_names):
if type_ in "schema":
return name in ["hame", "codes"]
else:
return True


# adapted from
# http://allan-simon.github.io/blog/posts/python-alembic-with-environment-variables/
def get_url(connection_params: dict):
Expand Down Expand Up @@ -72,6 +80,8 @@ def run_migrations_offline() -> None:
literal_binds=True,
dialect_opts={"paramstyle": "named"},
include_object=include_object,
include_schemas=True,
include_name=include_name,
)

with context.begin_transaction():
Expand All @@ -95,6 +105,8 @@ def run_migrations_online() -> None:
connection=connection,
target_metadata=target_metadata,
include_object=include_object,
include_schemas=True,
include_name=include_name,
)

with context.begin_transaction():
Expand Down

0 comments on commit 9f61e88

Please sign in to comment.