Profile: Add initial default customStatus and allow empty values
Fixes #20
This commit is contained in:
35
migrations/20220921103647-add-default-custom-status.js
Normal file
35
migrations/20220921103647-add-default-custom-status.js
Normal file
@@ -0,0 +1,35 @@
|
||||
'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
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user