snowballtools-base/packages/backend/src/entity/Deployment.ts
Nabarun Gogoi 8bbe2583cb Add createdBy column in deployments table (#51)
* Add and use createdBy field in deployment entity

* Use updated get deployments client method in UI

---------

Co-authored-by: neeraj <neeraj.rtly@gmail.com>
2024-02-01 11:37:57 +05:30

73 lines
1.2 KiB
TypeScript

import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
ManyToOne,
OneToOne,
JoinColumn
} from 'typeorm';
import { Project } from './Project';
import { Domain } from './Domain';
import { User } from './User';
export enum Environment {
Production = 'Production',
Preview = 'Preview',
Development = 'Development',
}
enum Status {
Building = 'Building',
Ready = 'Ready',
Error = 'Error',
}
@Entity()
export class Deployment {
@PrimaryGeneratedColumn()
id!: number;
@ManyToOne(() => Project, { onDelete: 'CASCADE' })
@JoinColumn({ name: 'projectId' })
project!: Project;
@OneToOne(() => Domain)
@JoinColumn({ name: 'domainId' })
domain!: Domain | null;
@Column('varchar')
branch!: string;
@Column('varchar')
commitHash!: string;
@Column('varchar')
title!: string;
@Column({
enum: Environment
})
environment!: Environment;
@Column('boolean', { default: false })
isCurrent!: boolean;
@Column({
enum: Status
})
status!: Status;
@ManyToOne(() => User)
@JoinColumn({ name: 'createdBy' })
createdBy!: User;
@CreateDateColumn()
createdAt!: Date;
@UpdateDateColumn()
updatedAt!: Date;
}