Skip to content

Omitting table names from the autogenerate process #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion backend/app/alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
config.set_main_option('sqlalchemy.url', SQLALCHEMY_DATABASE_URL)


def include_name(name, type_, parent_names):
if type_ == "table":
return name in target_metadata.tables
else:
return True


def run_migrations_offline():
"""Run migrations in 'offline' mode.

Expand All @@ -54,14 +61,19 @@ def run_migrations_offline():
target_metadata=target_metadata,
literal_binds=True,
dialect_opts={'paramstyle': 'named'},
include_name=include_name,
)

with context.begin_transaction():
context.run_migrations()


def do_run_migrations(connection):
context.configure(connection=connection, target_metadata=target_metadata)
context.configure(
connection=connection,
target_metadata=target_metadata,
include_name=include_name,
)

with context.begin_transaction():
context.run_migrations()
Expand Down