52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
|
|
import { TimestampedEntity } from './timestamped.entity';
|
|
|
|
export enum SurveyCampaignStatus {
|
|
DRAFT = 'DRAFT',
|
|
PLANNED = 'PLANNED',
|
|
IN_PROGRESS = 'IN_PROGRESS',
|
|
COMPLETED = 'COMPLETED',
|
|
CANCELLED = 'CANCELLED',
|
|
}
|
|
|
|
@Entity({ name: 'survey_campaigns' })
|
|
@Index('uq_survey_campaigns_code', ['code'], { unique: true })
|
|
@Index('idx_survey_campaigns_status', ['status'])
|
|
@Index('idx_survey_campaigns_scope_asset_id', ['scopeAssetId'])
|
|
@Index('idx_survey_campaigns_coordinator_user_id', ['coordinatorUserId'])
|
|
@Index('idx_survey_campaigns_planned_dates', ['plannedStartAt', 'plannedEndAt'])
|
|
export class SurveyCampaign extends TimestampedEntity {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string;
|
|
|
|
@Column({ type: 'varchar', length: 80 })
|
|
code!: string;
|
|
|
|
@Column({ type: 'varchar', length: 200 })
|
|
name!: string;
|
|
|
|
@Column({ type: 'text', nullable: true })
|
|
description!: string | null;
|
|
|
|
@Column({ type: 'varchar', length: 24, default: SurveyCampaignStatus.DRAFT })
|
|
status!: SurveyCampaignStatus;
|
|
|
|
@Column({ name: 'planned_start_at', type: 'timestamptz', nullable: true })
|
|
plannedStartAt!: Date | null;
|
|
|
|
@Column({ name: 'planned_end_at', type: 'timestamptz', nullable: true })
|
|
plannedEndAt!: Date | null;
|
|
|
|
@Column({ name: 'scope_asset_id', type: 'uuid', nullable: true })
|
|
scopeAssetId!: string | null;
|
|
|
|
@Column({ name: 'coordinator_user_id', type: 'uuid', nullable: true })
|
|
coordinatorUserId!: string | null;
|
|
|
|
@Column({ name: 'created_by', type: 'uuid', nullable: true })
|
|
createdBy!: string | null;
|
|
|
|
@Column({ name: 'updated_by', type: 'uuid', nullable: true })
|
|
updatedBy!: string | null;
|
|
}
|