-
Notifications
You must be signed in to change notification settings - Fork 306
Open
Description
Workflow consist of using atlas
to generate goose migrations.
Expected Behavior
Generating goose migrations, the down migration of adding a column with predefined constraints would try to drop the constraint and then the column, or simply drop the table.
Actual Behavior
The drop migration drops the column, and then attempts to drop the constraint, causing a SQL error due to the constraint not existing anymore.
Steps to Reproduce
- Create a starting schema:
create table sample_table ( id numeric, c1 numeric);
- Generate the initial migration with
atlas migrate diff --dir-format "goose" ...
- Add a column with a constraint to the schema:
create table sample_table ( id numeric, c1 numeric, c2 numeric check ( c2 <= 10) );
- Generate new migration, should have an invalid drop sequence (drops column before constraint, causing error):
-- +goose Up
-- modify "sample_table" table
ALTER TABLE "public"."sample_table" ADD CONSTRAINT "sample_table_c2_check" CHECK (c2 <= (10)::numeric), ADD COLUMN "c2" numeric NULL;
-- +goose Down
-- reverse: modify "sample_table" table
ALTER TABLE "public"."sample_table" DROP COLUMN "c2", DROP CONSTRAINT "sample_table_c2_check";
Notes
The ordering seems to be fine when the difference between a schema is removing a column/constraints, so that the simultaneous dropping is part of the up migration.
Metadata
Metadata
Assignees
Labels
No labels