'use strict'; module.exports = { async up(queryInterface, Sequelize) { await queryInterface.createTable('user_sessions', { session_id: { type: Sequelize.BIGINT, primaryKey: true, autoIncrement: true }, user_id: { type: Sequelize.BIGINT, allowNull: false, references: { model: 'users', key: 'user_id' }, onUpdate: 'CASCADE', onDelete: 'CASCADE' }, login_info: { type: Sequelize.JSONB, allowNull: true }, logout_info: { type: Sequelize.JSONB, allowNull: true }, refresh_token_hash: { type: Sequelize.TEXT, allowNull: true }, is_active: { type: Sequelize.BOOLEAN, defaultValue: true }, createdBy: { type: Sequelize.BIGINT, allowNull: true }, updatedBy: { type: Sequelize.BIGINT, allowNull: true }, deletedBy: { type: Sequelize.BIGINT, allowNull: true }, createdAt: { type: Sequelize.DATE, allowNull: false }, updatedAt: { type: Sequelize.DATE, allowNull: false }, deletedAt: { type: Sequelize.DATE, allowNull: true }, }); await queryInterface.addIndex('user_sessions', ['user_id']); }, async down(queryInterface) { await queryInterface.dropTable('user_sessions'); }, };