Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

queries are executed in reverse order during a rollback #13

Closed
robacarp opened this issue Jun 22, 2018 · 0 comments · Fixed by #14
Closed

queries are executed in reverse order during a rollback #13

robacarp opened this issue Jun 22, 2018 · 0 comments · Fixed by #14

Comments

@robacarp
Copy link
Contributor

This may not be a bug, but I found it counter intuitive. If it isn't a bug, it's behavior I found undocumented.

This migration assumes the existence of a table, and drops it. On rollback, it creates the table and an associated index.

-- +migrate Up
DROP TABLE routes;
-- SQL in section 'Up' is executed when this migration is applied

-- +migrate Down
CREATE TABLE routes(
  id BIGSERIAL PRIMARY KEY,
  foreign_key BIGINT,
);

CREATE INDEX routes_foreign_key_idx ON routes (foreign_key);
-- SQL section 'Down' is executed when this migration is rolled back

When executing #down on a migrator, this migration will fail because the table doesn't exist when the 'create index' is executed. I believe this is because statement order is reversed during a rollback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant