'use strict';
const {
  Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
  class Shipment 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
    }
  }
 Shipment.init({
  orderId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    unique: true
  },
  trackingNumber: {
    type: DataTypes.STRING,
    unique: true
  },
  carrier: {
    type: DataTypes.STRING,
    allowNull: false
  },
  method: {
    type: DataTypes.STRING
  },
  shippedAt: {
    type: DataTypes.DATE
  },
  estimatedDelivery: {
    type: DataTypes.DATE
  },
  deliveredAt: {
    type: DataTypes.DATE
  },
  status: {
    type: DataTypes.ENUM(
      'pending',
      'processing',
      'shipped',
      'in_transit',
      'out_for_delivery',
      'delivered',
      'failed_delivery',
      'returned',
      'cancelled',
      'lost'
    ),
    allowNull: false,
    defaultValue: 'pending'
  }
}, {
  sequelize,
  modelName: 'Shipment',
});
  return Shipment;
};