'use strict';
const { defaultKeys, migrationDefaults, relationShip } = require('../sequelize/defaults');
/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.createTable('expenses', {
      ...defaultKeys("expenses_id"),
      tbl_ref_id: {
        type: Sequelize.STRING,
        allowNull: true,
      },
      branch_id: relationShip({
        modelName: "branches",
        key: "branch_id",
        allowNull: false,
      }),
      item_category_id: relationShip({
        modelName: "item_categories",
        key: "item_category_id",
        allowNull: false,
      }),
      user_id: relationShip({
        modelName: "users",
        key: "user_id",
        allowNull: false,
      }),
      expenses_amount: {
        type: Sequelize.STRING,
        allowNull: false,
      },
      expenses_date: {
        type: Sequelize.DATEONLY,
        allowNull: false,
      },
      expenses_descp: {
        type: Sequelize.STRING,
        allowNull: true,
      },
      ...migrationDefaults(),
    });
  },
  async down(queryInterface, Sequelize) {
    await queryInterface.dropTable('expenses');
  }
};