import { DataTypes } from "sequelize";
import { sequelize } from "@/configs/sequelize";
import { User } from "./user";

export const Disease = sequelize.define(
    "Disease",
    {
        id: {
            type: DataTypes.UUID,
            primaryKey: true,
            defaultValue: DataTypes.UUIDV4,
        },
        name: {
            type: DataTypes.STRING,
            unique: true,
            allowNull: false,
        },
        description: {
            type: DataTypes.STRING,
            defaultValue: "",
        },
        severity: {
            type: DataTypes.ENUM("mild", "moderate", "severe"),
            defaultValue: "mild",
        },
        treatment: {
            type: DataTypes.STRING,
            defaultValue: "",
        },
        created_by_id: {
            type: DataTypes.UUID,
            allowNull: false,
        },
    },
    {
        tableName: "diseases",
        timestamps: true,
        createdAt: "created_at",
        updatedAt: "updated_at",
    },
);

Disease.belongsTo(User, {
    foreignKey: "created_by_id",
    as: "created_by",
});
