import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  CreateDateColumn,
  UpdateDateColumn,
} from 'typeorm';

@Entity('modules') // table name is 'modules'
export class ModuleEntity {
  @PrimaryGeneratedColumn({ type: 'int', name: 'id' })
  id: number;

  @Column('varchar', { length: 100, nullable: false })
  name: string; // e.g., "User Management"

  @Column('varchar', { length: 100, nullable: false, name: 'key_name' })
  keyName: string; // e.g., "user_management"

  @Column('varchar', { length: 255, nullable: true })
  description: string | null;

  @Column('enum', {
    enum: ['active', 'inactive'],
    default: 'active',
    nullable: false,
  })
  status: 'active' | 'inactive';

  @CreateDateColumn({ name: 'created_at', type: 'timestamp' })
  createdAt: Date;

  @UpdateDateColumn({ name: 'updated_at', type: 'timestamp' })
  updatedAt: Date;
}
