Skip to content

Commit

Permalink
fix: Don't create migration if there are no schema changes (#118)
Browse files Browse the repository at this point in the history
Don't create migration if there are no schema changes
  • Loading branch information
rzlim08 authored Oct 21, 2024
1 parent a4f7312 commit 979518b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions platformics/codegen/templates/database/migrations/env.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,19 @@ def run_migrations_online() -> None:
settings = CLISettings.model_validate({})
connectable = create_engine(settings.SYNC_DB_URI)

def process_revision_directives(context, revision, directives):
if config.cmd_opts.autogenerate:
script = directives[0]
if script.upgrade_ops.is_empty():
directives[:] = []
print('No changes in schema detected.')

with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata,
include_schemas=True,
process_revision_directives = process_revision_directives,
)

with context.begin_transaction():
Expand Down

0 comments on commit 979518b

Please sign in to comment.