'use strict';
const {
  Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
  class OrderStatus extends Model {
    /**
     * Helper method for defining associations.
     * This method is not a part of Sequelize lifecycle.
     * The `models/index` file will call this method automatically.
     */
    static associate(models) {
      // define association here
      OrderStatus.belongsTo(models.Order, { foreignKey: 'orderId', as: 'order' });
      
    }
  }
  OrderStatus.init({
    orderId: DataTypes.INTEGER,
    status: DataTypes.ENUM(
      'pending',
      'confirmed',
      'processing',
      'shipped',
      'delivered',
      'cancelled',
      'refunded',
      'failed'
    ),
    description: DataTypes.TEXT,
    updatedBy: DataTypes.INTEGER
  }, {
    sequelize,
    modelName: 'OrderStatus',
  });
  return OrderStatus;
};