-
Notifications
You must be signed in to change notification settings - Fork 2
Description
I’d like to start a discussion about improving how dbdiff handles updates to generated columns. At the moment, schema changes on these columns are treated as standard ALTER operations. However, PostgreSQL does not allow ALTER COLUMN for generated columns... you must drop and recreate the column instead.
This limitation creates a gap: when a generated column’s definition changes, dbdiff currently outputs an ALTER that will fail at runtime. A more robust approach would be to detect these cases and automatically produce the correct DROP COLUMN … ADD COLUMN sequence (ideally preserving constraints, defaults, indexes, and comments as needed).
I’d like to explore:
- Detecting generated column changes accurately in diffs
- Emitting the required drop-and-recreate statements safely
- Preserving dependent objects and comments during regeneration
Feedback on edge cases (for example: preserving data when possible, similar to how Enums work, or warning when data loss is unavoidable) would be especially helpful. Once we align on the desired functionality, I can move forward with an implementation and PR.