'use strict';
const { defaultKeys, migrationDefaults, relationShip } = require('../sequelize/defaults');

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.createTable('users', {
      ...defaultKeys("user_id"),
      branch_id: relationShip({
        modelName: "branches",
        key: "branch_id",
        allowNull: false,
      }),
      designation_id: relationShip({
        modelName: "designation",
        key: "designation_id",
        allowNull: true,
      }),
      fullname: {
        type: Sequelize.STRING,
        allowNull: true,
      },
      role: {
        type: Sequelize.STRING,
        allowNull: true,
      },
      mobile: {
        type: Sequelize.STRING,
        allowNull: false,
      },
      address: {
        type: Sequelize.STRING,
        allowNull: true,
      },
      status: {
        type: Sequelize.BOOLEAN,
        allowNull: true,
      },
      ...migrationDefaults({ isUser: true }),
    });
  },

  async down(queryInterface, Sequelize) {
    await queryInterface.dropTable('users');
  }
};
