45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
|
|
import { TimestampedEntity } from './timestamped.entity';
|
|
|
|
export enum SurveyTargetStatus {
|
|
PENDING = 'PENDING',
|
|
IN_PROGRESS = 'IN_PROGRESS',
|
|
SUBMITTED = 'SUBMITTED',
|
|
COMPLETED = 'COMPLETED',
|
|
SKIPPED = 'SKIPPED',
|
|
}
|
|
|
|
@Entity({ name: 'survey_campaign_targets' })
|
|
@Index('uq_survey_campaign_targets_campaign_asset', ['campaignId', 'assetId'], { unique: true })
|
|
@Index('idx_survey_campaign_targets_campaign_status', ['campaignId', 'status'])
|
|
@Index('idx_survey_campaign_targets_asset_id', ['assetId'])
|
|
@Index('idx_survey_campaign_targets_assigned_user_id', ['assignedUserId'])
|
|
export class SurveyCampaignTarget extends TimestampedEntity {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string;
|
|
|
|
@Column({ name: 'campaign_id', type: 'uuid' })
|
|
campaignId!: string;
|
|
|
|
@Column({ name: 'asset_id', type: 'uuid' })
|
|
assetId!: string;
|
|
|
|
@Column({ name: 'assigned_user_id', type: 'uuid', nullable: true })
|
|
assignedUserId!: string | null;
|
|
|
|
@Column({ type: 'varchar', length: 24, default: SurveyTargetStatus.PENDING })
|
|
status!: SurveyTargetStatus;
|
|
|
|
@Column({ name: 'due_at', type: 'timestamptz', nullable: true })
|
|
dueAt!: Date | null;
|
|
|
|
@Column({ type: 'text', nullable: true })
|
|
instructions!: string | null;
|
|
|
|
@Column({ name: 'created_by', type: 'uuid', nullable: true })
|
|
createdBy!: string | null;
|
|
|
|
@Column({ name: 'updated_by', type: 'uuid', nullable: true })
|
|
updatedBy!: string | null;
|
|
}
|