-
-
Notifications
You must be signed in to change notification settings - Fork 163
Description
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? :)