'use strict';
const {
  Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
  class Ticket 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
    }
  }
Ticket.init({
  userId: {
    type: DataTypes.INTEGER,
    allowNull: false
  },
  subject: {
    type: DataTypes.STRING,
    allowNull: false
  },
  category: {
    type: DataTypes.ENUM(
      'technical',
      'billing',
      'shipping',
      'product',
      'account',
      'refund',
      'complaint',
      'feedback',
      'other'
    ),
    allowNull: false,
    defaultValue: 'other'
  },
  priority: {
    type: DataTypes.ENUM(
      'low',
      'medium',
      'high',
      'urgent'
    ),
    allowNull: false,
    defaultValue: 'medium'
  },
  status: {
    type: DataTypes.ENUM(
      'open',
      'in_progress',
      'pending_customer',
      'pending_agent',
      'resolved',
      'closed',
      'cancelled'
    ),
    allowNull: false,
    defaultValue: 'open'
  },
  assignedTo: {
    type: DataTypes.INTEGER
  }
}, {
  sequelize,
  modelName: 'Ticket',
});
  return Ticket;
};