import db from "../../database/db.js";

const SectionModel = (DataTypes) => {
  const Sections = db.define(
    "section",
    {
      ID_SECTION: {
        type: DataTypes.UUID,
        primaryKey: true,
        defaultValue: DataTypes.UUIDV4,
        validate: {
          notEmpty: true,
        },
      },
      NAME_SECTION: {
        type: DataTypes.STRING(100),
        allowNull: false,
        validate: {
          notEmpty: true,
        },
      },
      DESCRIPTION_SECTION: {
        type: DataTypes.TEXT,
        allowNull: false,
        validate: {
          notEmpty: true,
        },
      },
      THUMBNAIL: {
        type: DataTypes.STRING(255),
        allowNull: true,
      },
      IS_DELETED: {
        type: DataTypes.TINYINT(1),
        allowNull: true,
        defaultValue: 0,
        validate: {
          min: 0,
          max: 1,
        },
      },
      TIME_SECTION: {
        type: DataTypes.DATE,
        allowNull: false,
        defaultValue: DataTypes.NOW,
      },
    },
    {
      timestamps: false, 
      tableName: "section",
    }
  );
  return Sections;
};

export default SectionModel;
