'use strict';
/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.createTable('Tickets', {
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: Sequelize.INTEGER
      },
      userId: {
        type: Sequelize.INTEGER,
        allowNull: false
      },
      subject: {
        type: Sequelize.STRING,
        allowNull: false
      },
      category: {
        type: Sequelize.ENUM(
          'technical',
          'billing',
          'shipping',
          'product',
          'account',
          'refund',
          'complaint',
          'feedback',
          'other'
        ),
        allowNull: false,
        defaultValue: 'other'
      },
      priority: {
        type: Sequelize.ENUM(
          'low',
          'medium',
          'high',
          'urgent'
        ),
        allowNull: false,
        defaultValue: 'medium'
      },
      status: {
        type: Sequelize.ENUM(
          'open',
          'in_progress',
          'pending_customer',
          'pending_agent',
          'resolved',
          'closed',
          'cancelled'
        ),
        allowNull: false,
        defaultValue: 'open'
      },
      assignedTo: {
        type: Sequelize.INTEGER
      },
      createdAt: {
        allowNull: false,
        type: Sequelize.DATE
      },
      updatedAt: {
        allowNull: false,
        type: Sequelize.DATE
      }
    });
  },
  async down(queryInterface, Sequelize) {
    await queryInterface.dropTable('Tickets');
  }
};