5 changed files with 75 additions and 9 deletions
@ -0,0 +1,45 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
/** @type {import('sequelize-cli').Migration} */ |
||||
|
module.exports = { |
||||
|
async up (queryInterface, Sequelize) { |
||||
|
/** |
||||
|
* Add altering commands here. |
||||
|
* |
||||
|
* Example: |
||||
|
* await queryInterface.createTable('users', { id: Sequelize.INTEGER }); |
||||
|
*/ |
||||
|
const transaction = await queryInterface.sequelize.transaction(); |
||||
|
try { |
||||
|
await queryInterface.addColumn( |
||||
|
'Racers', |
||||
|
'loginId', |
||||
|
{ |
||||
|
type: Sequelize.STRING, |
||||
|
}, |
||||
|
{ transaction } |
||||
|
); |
||||
|
await transaction.commit(); |
||||
|
} catch (err) { |
||||
|
await transaction.rollback(); |
||||
|
throw err; |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
async down (queryInterface, Sequelize) { |
||||
|
/** |
||||
|
* Add reverting commands here. |
||||
|
* |
||||
|
* Example: |
||||
|
* await queryInterface.dropTable('users'); |
||||
|
*/ |
||||
|
const transaction = await queryInterface.sequelize.transaction(); |
||||
|
try { |
||||
|
await queryInterface.removeColumn('Racers', 'loginId', { transaction }); |
||||
|
await transaction.commit(); |
||||
|
} catch (err) { |
||||
|
await transaction.rollback(); |
||||
|
throw err; |
||||
|
} |
||||
|
} |
||||
|
}; |
||||
Loading…
Reference in new issue