Skip to content

Commit 0bb6275

Browse files
authored
Omitting table names from the autogenerate process (#125)
1 parent 5c64d99 commit 0bb6275

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

backend/app/alembic/env.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@
3636
config.set_main_option('sqlalchemy.url', SQLALCHEMY_DATABASE_URL)
3737

3838

39+
def include_name(name, type_, parent_names):
40+
if type_ == "table":
41+
return name in target_metadata.tables
42+
else:
43+
return True
44+
45+
3946
def run_migrations_offline():
4047
"""Run migrations in 'offline' mode.
4148
@@ -54,14 +61,19 @@ def run_migrations_offline():
5461
target_metadata=target_metadata,
5562
literal_binds=True,
5663
dialect_opts={'paramstyle': 'named'},
64+
include_name=include_name,
5765
)
5866

5967
with context.begin_transaction():
6068
context.run_migrations()
6169

6270

6371
def do_run_migrations(connection):
64-
context.configure(connection=connection, target_metadata=target_metadata)
72+
context.configure(
73+
connection=connection,
74+
target_metadata=target_metadata,
75+
include_name=include_name,
76+
)
6577

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

0 commit comments

Comments
 (0)