import {
    Entity,
    PrimaryGeneratedColumn,
    Column,
    CreateDateColumn,
    UpdateDateColumn,
    ManyToOne,
    JoinColumn,
} from 'typeorm';
import { Plan } from './plan.entity';

@Entity('plan_permissions')
export class PlanPermission {
    @PrimaryGeneratedColumn('uuid')
    id: string;

    @Column({ type: 'uuid' })
    plan_id: string;

    @ManyToOne(() => Plan)
    @JoinColumn({ name: 'plan_id' })
    plan: Plan;

    @Column({ type: 'varchar', length: 255 })
    feature_name: string;

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

    @Column({ type: 'varchar', length: 255 })
    type: string;

    @Column({ type: 'integer', nullable: true })
    limits: number;

    @Column({ type: 'integer', default: 1 })
    order_by: number;

    @Column({ type: 'varchar', length: 50, nullable: true })
    time_period: string;

    @Column({ type: 'varchar', length: 50, nullable: true })
    time_period_type: string;

    @Column({ type: 'varchar', length: 10, nullable: true })
    comparison_operators: string;

    @Column({ type: 'boolean', default: true, comment: '' })
    is_enable: boolean;

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

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