Skip to content

Support Generated Column Diffs #6

@amerryma

Description

@amerryma

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions