diff --git a/pkg/migrations/op_add_column.go b/pkg/migrations/op_add_column.go index 43022662..b6595683 100644 --- a/pkg/migrations/op_add_column.go +++ b/pkg/migrations/op_add_column.go @@ -184,6 +184,12 @@ func (o *OpAddColumn) Validate(ctx context.Context, s *schema.Schema) error { return errors.New("adding primary key columns is not supported") } + // Update the schema to ensure that the new column is visible to validation of + // subsequent operations. + table.AddColumn(o.Column.Name, schema.Column{ + Name: TemporaryName(o.Column.Name), + }) + return nil } diff --git a/pkg/migrations/op_create_index_test.go b/pkg/migrations/op_create_index_test.go index 3b9cdc64..62eaeb5f 100644 --- a/pkg/migrations/op_create_index_test.go +++ b/pkg/migrations/op_create_index_test.go @@ -9,7 +9,6 @@ import ( "testing" "github.com/xataio/pgroll/pkg/migrations" - "github.com/xataio/pgroll/pkg/roll" ) func TestCreateIndex(t *testing.T) { @@ -417,5 +416,5 @@ func TestCreateIndexOnObjectsCreatedInSameMigration(t *testing.T) { IndexMustExist(t, db, schema, "users", "idx_users_age") }, }, - }, roll.WithSkipValidation(true)) // TODO: Remove once these migrations pass validation + }) }