mirror of
https://framagit.org/les/gancio.git
synced 2025-01-31 16:42:22 +01:00
23 lines
691 B
JavaScript
23 lines
691 B
JavaScript
const User = require('../api/models/user')
|
|
|
|
/** @type {import('sequelize-cli').Migration} */
|
|
module.exports = {
|
|
async up (queryInterface, Sequelize) {
|
|
async function go () {
|
|
await queryInterface.addColumn('users', 'role', {
|
|
type: Sequelize.ENUM,
|
|
values: ['admin', 'editor', 'user'],
|
|
defaultValue: 'user'
|
|
})
|
|
|
|
const user = User(queryInterface.sequelize, Sequelize.DataTypes)
|
|
await user.update({ role: 'admin'}, { where: { is_admin: true } })
|
|
}
|
|
return go()
|
|
},
|
|
|
|
async down (queryInterface, Sequelize) {
|
|
return queryInterface.removeColumn('users', 'role')
|
|
// await queryInterface.removeColumn('users', 'is_editor')
|
|
}
|
|
}
|