import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, ManyToOne, OneToMany, JoinColumn, } from 'typeorm'; import { AppRuntime, DatabaseType } from '../../common/enums'; import { User } from '../../users/entities/user.entity'; import { Deployment } from '../../deployments/entities/deployment.entity'; @Entity('applications') export class Application { @PrimaryGeneratedColumn('uuid') id: string; @Column() name: string; @Column({ nullable: true }) description: string; @Column({ type: 'enum', enum: AppRuntime }) runtime: AppRuntime; @Column({ type: 'enum', enum: DatabaseType, default: DatabaseType.NONE }) databaseType: DatabaseType; @Column({ nullable: true }) dbUsername: string; @Column({ nullable: true }) dbPassword: string; @Column({ nullable: true }) gitUrl: string; @Column({ nullable: true }) gitToken: string; // Personal access token for private repos @Column({ nullable: true }) gitBranch: string; // Branch to clone (default: main) @Column({ nullable: true }) codePath: string; // Path to uploaded zip @Column({ type: 'jsonb', nullable: true }) envVars: Record; // Resource configuration @Column({ default: '100m' }) cpuRequest: string; @Column({ default: '500m' }) cpuLimit: string; @Column({ default: '128Mi' }) memoryRequest: string; @Column({ default: '512Mi' }) memoryLimit: string; @Column({ default: 1 }) replicas: number; @Column({ default: 3000 }) port: number; // Relations @ManyToOne(() => User, (user: User) => user.applications, { onDelete: 'CASCADE' }) @JoinColumn({ name: 'userId' }) user: User; @Column() userId: string; @Column({ nullable: true }) clusterId: string; @Column({ nullable: true }) poolId: string; // Cluster pool used for load-balanced assignment @OneToMany(() => Deployment, (deployment: Deployment) => deployment.application) deployments: Deployment[]; // Metadata @Column({ nullable: true }) latestImageTag: string; @Column({ nullable: true }) subdomain: string; // .apps.cloudhost.local @CreateDateColumn() createdAt: Date; @UpdateDateColumn() updatedAt: Date; }