diff --git a/docs/en_US/release_notes_6_21.rst b/docs/en_US/release_notes_6_21.rst index 082e48110..c827b4eda 100644 --- a/docs/en_US/release_notes_6_21.rst +++ b/docs/en_US/release_notes_6_21.rst @@ -43,5 +43,6 @@ Bug fixes | `Issue #5810 `_ - Fix an issue where sequence owner is remove on sequence edit. | `Issue #5822 `_ - Do not allow to save invalid JSON in query tool JSON editor. | `Issue #5847 `_ - Fixed an issue where pgAdmin failed to connect when the Postgres password included special characters. + | `Issue #5870 `_ - Ensure that the database migration does not fail with a NoSuchTableError exception. | `Issue #5872 `_ - Handle MERGE operation in query tool explain introduced in PostgreSQL 15. | `Issue #5889 `_ - Fixed an issue where the database server is not connected using a service file. diff --git a/web/migrations/versions/f656e56dfdc8_.py b/web/migrations/versions/f656e56dfdc8_.py index 10abb7f7c..ef5063b21 100644 --- a/web/migrations/versions/f656e56dfdc8_.py +++ b/web/migrations/versions/f656e56dfdc8_.py @@ -32,6 +32,23 @@ def migrate_connection_params(table_name): op.add_column(table_name, sa.Column('connection_params', sa.JSON())) + # Fixed the NoSuchTableError exception when migrating from v6.2 and below + # to directly v6.16 and above. Below statements has been removed from + # migration file 3ce25f562f3b_.py as a part of using the alembic code + # instead of SQL queries directly. + try: + # Rename user table to user_old and again user_old to user to change + # the foreign key reference of user_old table which is not exists + op.execute("ALTER TABLE user RENAME TO user_old") + op.execute("ALTER TABLE user_old RENAME TO user") + # Rename user table to server_old and again server_old to server to + # change the foreign key reference of user_old table which is not + # exists. + op.execute("ALTER TABLE server RENAME TO server_old") + op.execute("ALTER TABLE server_old RENAME TO server") + except Exception as _: + pass + # define table representation meta = sa.MetaData(bind=op.get_bind()) meta.reflect(only=(table_name,))