db-migrate / node-db-migrate

Database migration framework for node
Other
2.32k stars 360 forks source link

autoIncrement: true stopped working #690

Closed gabrielhpugliese closed 4 years ago

gabrielhpugliese commented 4 years ago

Current behavior

Old migrations and new ones do not output auto increment anymore to any column

Expected behavior

SQL output should add auto increment to column

Minimal reproduction of the problem with instructions

Sample code:

exports.up = async function(db) {
  return await db.createTable('user_readings', {
    id: {
      type: 'int',
      primary: true,
      autoIncrement: true,
    },
  });
};

Dry run output:

$ db-migrate up -e $NODE_ENV --dry-run
[INFO] dry run
show server_version_num;
SHOW search_path;
SET search_path TO "$user","public";
SELECT table_name FROM information_schema.tables WHERE table_name = 'migrations' AND table_schema = 'public';
SELECT * FROM "migrations" ORDER BY run_on DESC, name DESC;
BEGIN;;
CREATE TABLE  "user_readings" ("id" INTEGER  ) ;
INSERT INTO "migrations" ("name", "run_on") VALUES ($1, $2) [ [ '/20200428080719-createUserReadingsTable',
    2020-04-28T09:39:29.577Z ] ]
[INFO] Processed migration 20200428080719-createUserReadingsTable
COMMIT;;
[INFO] Done
   Done in 0.53s.

What is the motivation / use case for changing the behavior?

Am I missing anything here? It worked like charm before and after I update packages it's not working anymore.

Environment

Deps:

success Saved lockfile.
success Saved 8 new dependencies.
info Direct dependencies
└─ db-migrate@0.11.10
info All dependencies
├─ db-migrate@0.11.10
├─ deep-equal@0.2.2
├─ i@0.3.6
├─ ncp@1.0.1
├─ pkginfo@0.4.1
├─ prompt@1.0.0
├─ revalidator@0.1.8
└─ utile@0.3.0
success Saved lockfile.                                                                                                                                                                                     success Saved 3 new dependencies.
info Direct dependencies                                                                                                                                                                                    └─ db-migrate-pg@1.2.1
info All dependencies
├─ db-migrate-base@2.3.0
├─ db-migrate-pg@1.2.1
└─ pg-packet-stream@1.1.0

Additional information:

I also tried the v1.0.0-beta.7 but it shows same results

wzrdtales commented 4 years ago

your migrations are wrong (there is no such option as primary, only primaryKey) not db-migrate, please read the documentation more carefully before opening an issue like this and make sure you're not doing it wrong:

https://db-migrate.readthedocs.io/en/latest/API/SQL/#createtabletablename-columnspec-callback

gabrielhpugliese commented 4 years ago

Sorry about it. Thanks.