Skip to content

Commit

Permalink
Merge branch 'master' of github.com:nens/threedi-schema
Browse files Browse the repository at this point in the history
  • Loading branch information
margrietpalm committed Sep 30, 2024
2 parents 7fe42c3 + 62041f5 commit 6d31013
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Changelog of threedi-schema
0.226.5 (unreleased)
--------------------

- Nothing changed yet.

- Prevent migrations 225 and 226 from failing when any of the new table names already exists
- Propagate changes from 0.225.6.


0.226.4 (2024-09-25)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,16 @@ def populate_table(table: str, values: dict):
op.execute(sa.text(query))


def drop_conflicting():
new_tables = [new_name for _, new_name in RENAME_TABLES]
for table_name in new_tables:
op.execute(f"DROP TABLE IF EXISTS {table_name};")


def upgrade():
# Drop tables that conflict with new table names
drop_conflicting()

# rename existing tables
rename_tables(RENAME_TABLES)

Expand Down
8 changes: 8 additions & 0 deletions threedi_schema/migrations/versions/0226_upgrade_db_1d_1d2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,15 @@ def set_potential_breach_final_exchange_level():
))


def drop_conflicting():
new_tables = [new_name for _, new_name in RENAME_TABLES]
for table_name in new_tables:
op.execute(f"DROP TABLE IF EXISTS {table_name};")


def upgrade():
# Drop tables that conflict with new table names
drop_conflicting()
rem_tables = []
for old_table_name, new_table_name in RENAME_TABLES:
modify_table(old_table_name, new_table_name)
Expand Down

0 comments on commit 6d31013

Please sign in to comment.