import { DataTypes, InferAttributes, InferCreationAttributes, Model } from "sequelize"; import { sequelize } from "../../../../config/database"; export type AuthUserCreationAttributes = InferCreationAttributes; class AuthUserModel extends Model< InferAttributes, InferCreationAttributes > { public id!: string; public username!: string; public email!: string; public password!: string; public roles!: string[]; public isActive!: boolean; } AuthUserModel.init( { id: { type: DataTypes.UUID, primaryKey: true, allowNull: false, }, username: { type: DataTypes.STRING, allowNull: false, }, email: { type: DataTypes.STRING, allowNull: false, unique: true, }, password: { type: DataTypes.STRING, allowNull: false, }, roles: { type: DataTypes.ARRAY(DataTypes.STRING), allowNull: false, defaultValue: [], }, isActive: { type: DataTypes.BOOLEAN, defaultValue: true, }, }, { sequelize, tableName: "users", paranoid: true, // softs deletes timestamps: true, createdAt: "created_at", updatedAt: "updated_at", deletedAt: "deleted_at", indexes: [{ name: "email_idx", fields: ["email"], unique: true }], } ); export { AuthUserModel };