'use strict';
const { defaultKeys, migrationDefaults, relationShip } = require('../sequelize/defaults');
/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.createTable('order_details', {
      ...defaultKeys("order_detail_id"),
      tbl_ref_id: {
        type: Sequelize.STRING,
        allowNull: true,
      },
      order_id: relationShip({
        modelName: "orders",
        key: "order_id",
        allowNull: true,
      }),
      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,
      },
      order_status: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: 'New',
      },
      ...migrationDefaults({ isUser: true }),
    });
  },
  async down(queryInterface, Sequelize) {
    await queryInterface.dropTable('order_details');
  }
};