const Sequelize = require("sequelize");
const sequelizeConnect = require("../connection/db");

const OrderStatusEvents = sequelizeConnect.define(
  "order_status_events",
  {
    id: {
      type: Sequelize.BIGINT,
      primaryKey: true,
      allowNull: false,
      autoIncrement: true,
    },
    order_id: {
      type: Sequelize.BIGINT,
      allowNull: false,
    },
    seller_id: {
      type: Sequelize.BIGINT,
      allowNull: false,
    },
    logistics_id: {
      type: Sequelize.BIGINT,
      allowNull: true,
    },
    old_status: {
      type: Sequelize.STRING(50),
      allowNull: true,
    },
    new_status: {
      type: Sequelize.STRING(50),
      allowNull: true,
    },
    processed_admin: {
      type: Sequelize.BOOLEAN,
      allowNull: false,
      defaultValue: false,
    },
    processed_seller: {
      type: Sequelize.BOOLEAN,
      allowNull: false,
      defaultValue: false,
    },
    processed_driver: {
      type: Sequelize.BOOLEAN,
      allowNull: false,
      defaultValue: false,
    },
    processed_warehouse: {
      type: Sequelize.BOOLEAN,
      allowNull: false,
      defaultValue: false,
    },
    processed_logistics: {
      type: Sequelize.BOOLEAN,
      allowNull: false,
      defaultValue: false,
    },
    processed_orders: {
      type: Sequelize.BOOLEAN,
      allowNull: false,
      defaultValue: false,
    },
    created_at: {
      type: Sequelize.DATE,
      allowNull: false,
      defaultValue: Sequelize.NOW,
    },
  },
  {
    tableName: "order_status_events",
    timestamps: false,
  },
);

module.exports = OrderStatusEvents;
