mirror of
https://framagit.org/les/gancio.git
synced 2025-01-31 16:42:22 +01:00
23 lines
966 B
JavaScript
23 lines
966 B
JavaScript
'use strict';
|
|
|
|
/** @type {import('sequelize-cli').Migration} */
|
|
module.exports = {
|
|
async up (queryInterface, Sequelize) {
|
|
// needed as in sequelize there is no support for alter table and sequelize simulate this by creating a backup table and dropping the old one:
|
|
// this will cause a foreign key error
|
|
const dialect = queryInterface.sequelize.getDialect()
|
|
if (dialect === 'sqlite') {
|
|
await queryInterface.sequelize.query('PRAGMA foreign_keys = OFF')
|
|
}
|
|
|
|
await queryInterface.changeColumn('places', 'name', { type: Sequelize.STRING, index: true, allowNull: false, unique: false })
|
|
},
|
|
|
|
async down (queryInterface, Sequelize) {
|
|
const dialect = queryInterface.sequelize.getDialect()
|
|
if (dialect === 'sqlite') {
|
|
await queryInterface.sequelize.query('PRAGMA foreign_keys = OFF')
|
|
}
|
|
await queryInterface.changeColumn('places', 'name', { type: Sequelize.STRING, index: true, allowNull: false, unique: true })
|
|
}
|
|
};
|