import { sequelize } from '../../utils/sequelize.js';
import { DataTypes } from 'sequelize';

const Objective = sequelize.define('Objective', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  levelId: {
    type: DataTypes.INTEGER,
    allowNull: false
  },
  type: {
    type: DataTypes.ENUM('score', 'matches', 'moves', 'time', 'special'),
    allowNull: false
  },
  description: {
    type: DataTypes.STRING(500),
    allowNull: false
  },
  target: {
    type: DataTypes.INTEGER,
    allowNull: false
  },
  operator: {
    type: DataTypes.ENUM('>=', '<=', '=', '>', '<'),
    defaultValue: '>='
  },
  order: {
    type: DataTypes.INTEGER,
    defaultValue: 1
  },
  isRequired: {
    type: DataTypes.BOOLEAN,
    defaultValue: true
  },
  createdAt: {
    type: DataTypes.DATE,
    defaultValue: DataTypes.NOW
  },
  updatedAt: {
    type: DataTypes.DATE,
    defaultValue: DataTypes.NOW
  }
}, {
  tableName: 'match3_objectives',
  schema: 'match3',
  timestamps: true,
  underscored: true  // WICHTIG: Alle Datenbankfelder im snake_case Format
});

export default Objective;
