/* eslint-disable */
'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    await queryInterface.createTable("admins", {
      "id": { type: Sequelize.BIGINT, allowNull: false, primaryKey: true, autoIncrement: true },
      "role": { type: Sequelize.ENUM("admin", "superadmin"), defaultValue: "admin" },
      "first_name": { type: Sequelize.STRING(50) },
      "email": { type: Sequelize.STRING(255), allowNull: false, unique: true },
      "password": { type: Sequelize.STRING(255), allowNull: false },
      "timezone": { type: Sequelize.STRING(50), defaultValue: "UTC" },
      "date_format": { type: Sequelize.STRING(20), defaultValue: "MM/DD/YYYY" },
      "status": { type: Sequelize.ENUM("active", "inactive", "suspended", "pending"), defaultValue: "pending" },
      "login_notifications": { type: Sequelize.BOOLEAN, defaultValue: true },
      "password_reset_token": { type: Sequelize.STRING(255) },
      "password_reset_expires": { type: Sequelize.DATE },
      "password_changed_at": { type: Sequelize.DATE },
      "last_login": { type: Sequelize.DATE },
      "last_login_ip": { type: Sequelize.STRING(45) },
      "last_login_device": { type: Sequelize.STRING(255) },
      "login_attempts": { type: Sequelize.INTEGER, defaultValue: 0 },
      "lock_until": { type: Sequelize.DATE },
      "quiet_hours": { type: Sequelize.JSON, defaultValue: {"enabled":false,"start":"22:00","end":"07:00"} },
      "metadata": { type: Sequelize.JSON, defaultValue: {} },
      "created_at": { type: Sequelize.DATE, allowNull: false },
      "updated_at": { type: Sequelize.DATE, allowNull: false }
    }, {
      charset: 'utf8mb4',
      collate: 'utf8mb4_unicode_ci',
      engine: 'InnoDB',
    });
    await queryInterface.addIndex("admins", ["email"], {"name":"admins_email"});
    await queryInterface.addIndex("admins", ["status"], {"name":"admins_status"});
  },

  down: async (queryInterface) => {
    await queryInterface.dropTable("admins");
  },
};
