sqlmesh icon indicating copy to clipboard operation
sqlmesh copied to clipboard

Rollback (downgrade 0.224.0 → 0.209.0) fails due to dependent view on sqlmesh._snapshots

Open nickmuoh opened this issue 4 months ago • 1 comments

Description

Running sqlmesh rollback after downgrading from sqlmesh 0.224.0 to 0.209.0 raises a PostgreSQL dependency error. The process attempts to drop table sqlmesh._snapshots while view sqlmesh.model_snapshots still depends on it, causing the rollback to abort and leaving state objects partially reverted.

Error Snippet

psycopg2.errors.DependentObjectsStillExist: cannot drop table sqlmesh._snapshots because other objects depend on it
DETAIL:  view sqlmesh.model_snapshots depends on table sqlmesh._snapshots

Steps to Reproduce

  1. Install and run with sqlmesh 0.224.0 (state initialized).
  2. Downgrade dependency to sqlmesh 0.209.0.
  3. Execute sqlmesh rollback.
  4. Observe failure.

Actual Result

Rollback halts with a dependency error; state not fully rolled back.

Expected Result

Rollback completes without dependency errors and state objects are reverted consistently.

Impact

Prevents rollback during version downgrade; leaves residual state.

Environment

Database: PostgreSQL
Previous version: 0.224.0
Downgraded to: 0.209.0
Python: 3.10.x
Platform: Windows (dev environment)

nickmuoh avatar Sep 30 '25 19:09 nickmuoh

SQLMesh doesn't create a view called sqlmesh.model_snapshots in its state database. Is this something specific to your environment?

erindru avatar Sep 30 '25 19:09 erindru