You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The following error occurs when attempting to drop a column that is used by a view.
Error: executing migration statement. the database maybe be in a dirty state:
{ALTER TABLE "public"."person" DROP COLUMN "name" 3s 3s
[DELETES_DATA: Deletes all values in the column]}:
ERROR: cannot drop column name of table person because other objects depend on it (SQLSTATE 2BP01)
Expected behavior
If the DELETES_DATA hazard is allowed, the column should be dropped with CASCADE.
To Reproduce
Start with this SQL:
CREATETABLEperson (
id serialPRIMARY KEY,
name text
);
CREATEVIEWperson_viewASSELECT name FROM person;
Run the migration:
pg-schema-diff apply
Update it to this:
CREATETABLEperson (
id serialPRIMARY KEY,
first_name text,
last_name text
);
CREATEVIEWperson_viewASSELECT
first_name,
last_name
FROM person;
We intentionally do not cascade deletes -- this is to avoid implicit deletes. We want all deletes to be done explicitly, i.e., it's a better behavior to fail loudly then implicitly delete the view. This is really just an unfortunate consequence of views not being supported.
Describe the bug
The following error occurs when attempting to drop a column that is used by a view.
Expected behavior
If the DELETES_DATA hazard is allowed, the column should be dropped with
CASCADE
.To Reproduce
Context
pg-schema-diff version: 5fe8259
pg-schema-diff usage: CLI
Postgres version: 14
The text was updated successfully, but these errors were encountered: