Skip to content

Generate ALTER COLUMN operations when column type/constraints change #7

@jvatic

Description

@jvatic

Changing a column's type or constraints generates a migration with an empty ALTER TABLE statement for that table, e.g.:

If running sql-schema schema generates

-- schema.sql
CREATE TABLE foo (
    bar INT
);

Then changing INT to TEXT (or anything else) and running sql-schema migration will generate a migration with an empty ALTER TABLE foo (or nothing at all after #11 / v0.6.2).

This is because the we're currently only comparing at the column name level and performing DROP COLUMN or ADD COLUMN operations.

For PostgreSQL, it should generate something like

-- 002_alter_foo.up.sql
ALTER TABLE foo
    ALTER COLUMN bar SET DATA TYPE TEXT -- TODO: USING ...;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions