'use strict';
const { defaultKeys, migrationDefaults, relationShip } = require('../sequelize/defaults');
/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.createTable('customers', {
      ...defaultKeys("customer_id"),
      tbl_ref_id: {
        type: Sequelize.STRING,
        allowNull: true,
      },
      branch_id: relationShip({
        modelName: "branches",
        key: "branch_id",
        allowNull: false,
      }),
      area_id: relationShip({
        modelName: "areas",
        key: "area_id",
        allowNull: false,
      }),
      landmark_id: relationShip({
        modelName: "landmarks",
        key: "landmark_id",
        allowNull: false,
      }),
      customer_name: {
        type: Sequelize.STRING,
        allowNull: false,
      },
      mobile_number: {
        type: Sequelize.STRING,
        allowNull: true,
      },
      customer_descp: {
        type: Sequelize.STRING,
        allowNull: true,
      },
      active_status: {
        type: Sequelize.BOOLEAN,
        allowNull: false,
        defaultValue: 1,
      },
      ...migrationDefaults(),
    });
  },
  async down(queryInterface, Sequelize) {
    await queryInterface.dropTable('customers');
  }
};