Files
toho-miku/migrations/20220921103647-add-default-custom-status.js

36 lines
973 B
JavaScript

'use strict';
module.exports = {
async up (queryInterface, Sequelize) {
/**
* Add altering commands here.
*
* Example:
* await queryInterface.createTable('users', { id: Sequelize.INTEGER });
*/
let defaultStatus = "Hello, I'm new here!";
//Replace existin null values with default
await queryInterface.sequelize.query(`UPDATE Profiles SET customStatus = "${defaultStatus}" WHERE customStatus IS NULL`);
//Update column defaults
await queryInterface.changeColumn('Profiles', 'customStatus', {
type: Sequelize.STRING,
allowNull: false,
defaultValue: defaultStatus
});
},
async down (queryInterface, Sequelize) {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
await queryInterface.changeColumn('Profiles', 'customStatus', {
type: Sequelize.STRING,
allowNull: true,
defaultValue: null
});
}
};