import { Table, Column, Model, DataType, Length, UpdatedAt, CreatedAt, ForeignKey, BelongsTo, HasMany } from "sequelize-typescript"; @Table({ tableName: "sections", modelName: "Section" }) export default class Section extends Model { @Column({ primaryKey: true, autoIncrement: true, type: DataType.INTEGER }) declare id: number; @Length({ min: 1 }) @Column({ allowNull: false, defaultValue: "Unknown", type: DataType.STRING }) declare name: string; @CreatedAt declare created_at: Date; @UpdatedAt declare updated_at: Date; @ForeignKey(() => Section) @Column({ type: DataType.INTEGER }) declare root_section_id: number | null; @BelongsTo(() => Section, "root_section_id") declare root_section: Section; @HasMany(() => Section, "root_section_id") declare inner_sections: Section[]; }