import { DataTypes } from 'sequelize';

export default function defineJobTask(sequelize) {
  return sequelize.define(
    'JobTask',
    {
      id: { type: DataTypes.BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true },
      job_card_id: { type: DataTypes.BIGINT.UNSIGNED, allowNull: false },
      service_id: { type: DataTypes.BIGINT.UNSIGNED, allowNull: false },
      employee_id: { type: DataTypes.BIGINT.UNSIGNED, allowNull: true },
      status: {
        type: DataTypes.ENUM('pending', 'in_progress', 'completed'),
        allowNull: false,
        defaultValue: 'pending',
      },
      sub_tasks: {
        type: DataTypes.JSON,
        allowNull: true,
        defaultValue: [],
      },
      created_at: {
        type: DataTypes.DATE(3),
        allowNull: false,
        defaultValue: DataTypes.NOW,
      },
    },
    { tableName: 'job_tasks' }
  );
}
