node-api-template/db/migrations/20240313200650-create-user.js

64 lines
1.5 KiB
JavaScript
Raw Normal View History

2024-07-03 18:52:30 +00:00
'use strict';
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.createTable('users', {
id: {
type: Sequelize.DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true,
},
username: {
type: Sequelize.DataTypes.STRING,
allowNull: false,
unique: true,
},
email: {
type: Sequelize.DataTypes.STRING,
allowNull: true,
unique: true,
validate: {
isEmail: true,
},
},
password: {
type: Sequelize.DataTypes.STRING,
allowNull: false,
},
strategy: {
type: Sequelize.DataTypes.STRING,
allowNull: false,
defaultValue: 'local',
},
identifier: {
type: Sequelize.DataTypes.STRING,
allowNull: true,
},
active: {
type: Sequelize.DataTypes.BOOLEAN,
allowNull: false,
defaultValue: true,
},
createdAt: {
type: Sequelize.DataTypes.DATE,
allowNull: false,
defaultValue: Sequelize.DataTypes.NOW,
},
updatedAt: {
type: Sequelize.DataTypes.DATE,
allowNull: false,
defaultValue: Sequelize.DataTypes.NOW,
},
deletedAt: {
type: Sequelize.DataTypes.DATE,
allowNull: true,
},
});
},
async down(queryInterface) {
await queryInterface.dropTable('users');
},
};