import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, Index, ManyToMany, JoinTable, } from 'typeorm'; import { Permission } from './permission.entity'; @Entity({ schema: 'users', name: 'roles' }) export class Role { @PrimaryGeneratedColumn('uuid') id: string; @Column({ type: 'uuid' }) @Index() tenant_id: string; @Column({ type: 'varchar', length: 100 }) name: string; @Column({ type: 'varchar', length: 50 }) @Index() code: string; @Column({ type: 'varchar', length: 100 }) @Index() slug: string; @Column({ type: 'text', nullable: true }) description: string | null; @Column({ type: 'jsonb', nullable: true }) permissions: string[] | null; @Column({ type: 'uuid', nullable: true }) parent_role_id: string | null; @Column({ type: 'int', default: 0 }) level: number; @Column({ type: 'boolean', default: false }) is_system: boolean; @Column({ type: 'boolean', default: true }) is_active: boolean; @Column({ type: 'jsonb', nullable: true }) metadata: Record | null; @CreateDateColumn({ type: 'timestamp with time zone' }) created_at: Date; @UpdateDateColumn({ type: 'timestamp with time zone' }) updated_at: Date; @Column({ type: 'uuid', nullable: true }) created_by: string | null; // Relations will be handled via service queries for now // to avoid complex eager loading issues }