'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_details', {
      ...defaultKeys("return_detail_id"),
      tbl_ref_id: {
        type: Sequelize.STRING,
        allowNull: true,
      },
      return_id: relationShip({
        modelName: "order_return",
        key: "return_id",
        allowNull: true,
      }),
      order_detail_id: relationShip({
        modelName: "order_details",
        key: "order_detail_id",
        allowNull: false,
      }),
      product_id: relationShip({
        modelName: "products",
        key: "product_id",
        allowNull: true,
      }),
      price: {
        type: Sequelize.INTEGER,
        allowNull: false,
      },
      quantity: {
        type: Sequelize.INTEGER,
        allowNull: false,
      },
      amount: {
        type: Sequelize.DOUBLE,
        allowNull: false,
      },
      type: {
        type: Sequelize.STRING,
        allowNull: false,
      },
      ...migrationDefaults({ isUser: true }),
    });
  },
  async down(queryInterface, Sequelize) {
    await queryInterface.dropTable('order_return_details');
  }
};