<#6870 feat: downgrade system DB to earlier versio...
# meltano-repo-activity
g
#6870 feat: downgrade system DB to earlier version Issue created by DouweM Feature scope CLI (options, error messages, logging, etc.) Description When you upgrade Meltano, find that something doesn't work as expected, don't have time to fix it, and want to roll back to an earlier version, you immediately run into a problem: the system DB has already automatically been upgraded, and any Meltano command shows an error like:
Copy code
alembic.script.revision.ResolutionError: No such revision or branch '6828cc5b1a4f'
Cannot upgrade the system database. It might be corrupted or was created before database migrations where introduced (v0.34.0)
(psycopg2.errors.UndefinedTable) relation "job" does not exist
We can: 1. Make that error message more clear 2. Provide a way to downgrade the system DB to that corresponding to an older Meltano version. That needs to happen on the latest version since the revisions to rolled back need to be available, but then after downgrading Meltano itself any new commands should work again. Any data loss because of new tables/columns being dropped should not affect the earlier version. For a temporary workaround, I suggested this to a user who ran into this, but this leaves most of this as an exercise to the reader: • You can run
meltano repl
and then try to get your hand on the alembic context • But you’d need to do that on the latest version so that it has all the revisions it needs to walk through backwards • There, you can run
engine, session = project_engine(project, default=True)
to get your hands on the SQLalchemy engine • And then the code in meltano/src/meltano/core/migration_service.py Line 32 in</meltano/meltano/commit/a12adf681dbff0ee8ac91d7e6f3a5ad1c417c0a1|a12adf6> | class MigrationService: | | ----------------------- | can serve as inspiration to make the right alembic incantations meltano/meltano