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

UP ALLOW not working correctly #621

Closed
nicoabie opened this issue Sep 22, 2023 · 1 comment
Closed

UP ALLOW not working correctly #621

nicoabie opened this issue Sep 22, 2023 · 1 comment

Comments

@nicoabie
Copy link

  • the full umzug version you're using 3.3.1
  • which storage you're using SequelizeStorage

I run npm run umzug down -- --name 0480_create_materialized_db.ts --rerun ALLOW

and I get

Error: Validation error

if I run down and then up on that migration it works so the allow is not working correctly

@mmkal
Copy link
Contributor

mmkal commented Nov 4, 2023

It looks to be working. I think what you saw was just a confusing error from Sequelize, that umzug is unhelpfully hiding most of. Error: Validation error is the top-level message when you try to create a table which already exists. You probably have a call like await sequelize.getQueryInterface().createTable('users', ...) in your migration, and Sequelize is throwing because users already exists.

The full error will look something more like this:

Error
    at Database.<anonymous> (/Users/mmkal/src/umzug/node_modules/sequelize/src/dialects/sqlite/query.js:236:27)
    at /Users/mmkal/src/umzug/node_modules/sequelize/src/dialects/sqlite/query.js:234:50
    at new Promise (<anonymous>)
    at Query.run (/Users/mmkal/src/umzug/node_modules/sequelize/src/dialects/sqlite/query.js:234:12)
    at /Users/mmkal/src/umzug/node_modules/sequelize/src/sequelize.js:650:28
    at async SQLiteQueryInterface.insert (/Users/mmkal/src/umzug/node_modules/sequelize/src/dialects/abstract/query-interface.js:795:21)
    at async model.save (/Users/mmkal/src/umzug/node_modules/sequelize/src/model.js:4073:35)
    at async Function.create (/Users/mmkal/src/umzug/node_modules/sequelize/src/model.js:2280:12)
    at async SequelizeStorage.logMigration (/Users/mmkal/src/umzug/lib/storage/sequelize.js:56:9)
    at async /Users/mmkal/src/umzug/lib/umzug.js:153:17 {
  name: 'SequelizeUniqueConstraintError',
  errors: [
    ValidationErrorItem {
      message: 'name must be unique',
      type: 'unique violation',
      path: 'name',
      value: '2020.11.24T16.52.04.users-table.ts',
      origin: 'DB',
      instance: [migration_meta],
      validatorKey: 'not_unique',
      validatorName: null,
      validatorArgs: []
    }
  ],
  parent: [Error: SQLITE_CONSTRAINT_PRIMARYKEY: UNIQUE constraint failed: migration_meta.name] {
    errno: 1555,
    code: 'SQLITE_CONSTRAINT_PRIMARYKEY',
    sql: 'INSERT INTO `migration_meta` (`name`) VALUES ($1);'
  },
  original: [Error: SQLITE_CONSTRAINT_PRIMARYKEY: UNIQUE constraint failed: migration_meta.name] {
    errno: 1555,
    code: 'SQLITE_CONSTRAINT_PRIMARYKEY',
    sql: 'INSERT INTO `migration_meta` (`name`) VALUES ($1);'
  },
  fields: [ 'name' ],
  sql: 'INSERT INTO `migration_meta` (`name`) VALUES ($1);'
}

So, I'll close this, but feel free to watch for a fix to #619. Or if you think there's still something wrong, please open a new issue with a repro, or a test which showcases the problem. The existing rerun tests are a good reference point.

@mmkal mmkal closed this as completed Nov 4, 2023
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