Skip to content

Calling up, down and up again with paranoid sequelize storage gives uniqness error for Migrations table #706

@kottofey

Description

@kottofey

Umzug ver. 3.8.2
Storage: Sequelize
Node v23
Using TS

I set up Sequelize storage to Paranoid mode like this (with timestamps on):

export const migrator = new Umzug({
  migrations: {
    glob: ['../sequelize/migrations/*.ts', { cwd: __dirname }],
  },
  context: sequelize,
  storage: new SequelizeStorage({
    sequelize,
    tableName: 'Migrations',
    timestamps: true,
  }),
  logger: console,
});

Then I run a migration up — it creates a record in Migrations table and marks its createdAt and UpdatedAt fields respectively.

Then I run migration down — it does not delete a record but marks its deletedAt field. Which is absolutely correct in paranoid mode.

But now when I try to run this very same migration up again it fails due to uniqueness error because there is a record with same migration name exists already:

Executing (default): INSERT INTO `Migrations` (`name`,`createdAt`,`updatedAt`) VALUES (?,?,?);

Error: Validation error

My understanding of a workflow is: i try to write a migration, run it up, if there is something i don't like — roll it back with migration down, change something and run it up again, check etc.

A solution is to stop using paranoid mode to make a migration record disappear from Migrations table, but... Maybe i use the Umzug in a wrong way? :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions