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

"node-pg-migrate down" doesn't work when the "down" method is inferred #84

Closed
jhs67 opened this issue May 16, 2017 · 1 comment
Closed

Comments

@jhs67
Copy link

jhs67 commented May 16, 2017

Create a migration with no down method:

exports.up = function(pgm) {
  pgm.createTable("foo", { bar: "id" });
};

Run pg-migrate up and it shows:

### MIGRATION 1494965078152_foo (UP) ###
BEGIN;
CREATE TABLE "foo" (
  "bar" serial PRIMARY KEY
);
INSERT INTO "public"."pgmigrations" (name, run_on) VALUES ('1494965078152_foo', NOW());
COMMIT;

Then run pg-migrate down and it shows:

### MIGRATION 1494965078152_foo (UP) ###
BEGIN;
DROP TABLE "foo";
INSERT INTO "public"."pgmigrations" (name, run_on) VALUES ('1494965078152_foo', NOW());
COMMIT;

Note that is says it is running the UP migration, runs the command from the correct down migration, and then INSERT's instead of DELETE's from the pgmigrations table.

The problem seems to stem from the switch at line 59 of migrations.js. When the down migration is inferred this.up == this.down (see line 103 of migrations.js) so it always run the up action.

@dolezel
Copy link
Contributor

dolezel commented May 18, 2017

Thanks for reporting! Will check

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

No branches or pull requests

2 participants