'use strict';
const { defaultKeys, migrationDefaults, relationShip } = require('../sequelize/defaults');
/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.createTable('order_return', {
      ...defaultKeys("return_id"),
      tbl_ref_id: {
        type: Sequelize.STRING,
        allowNull: true,
      },
      branch_id: relationShip({
        modelName: "branches",
        key: "branch_id",
        allowNull: false,
      }),
      order_id: relationShip({
        modelName: "orders",
        key: "order_id",
        allowNull: true,
      }),
      return_date: {
        type: Sequelize.DATEONLY,
        allowNull: false,
      },
      total_amount: {
        type: Sequelize.DECIMAL(10, 2),
        allowNull: false,
      },
      ...migrationDefaults({ isUser: true }),
    });
  },
  async down(queryInterface, Sequelize) {
    await queryInterface.dropTable('order_return');
  }
};