import {
    Column,
    CreateDateColumn,
    Entity,
    OneToMany,
    PrimaryGeneratedColumn,
    UpdateDateColumn,
} from 'typeorm';
import { User } from '../user/user.entity';
import { TenantMember } from './tenant-member.entity';

@Entity('tenants')
export class Tenant {
    @PrimaryGeneratedColumn('uuid')
    id: string;

    @Column({ type: 'text', unique: true })
    name: string;

    @Column({ type: 'text', unique: true, nullable: true })
    domain: string;

    @Column({ type: 'text', default: '{}' })
    settings: string;

    @Column({ name: 'default_model_id', type: 'text', nullable: true })
    defaultModelId: string;

    @OneToMany(() => TenantMember, (member) => member.tenant)
    members: TenantMember[];

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

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