diff options
Diffstat (limited to 'db/schema/evaluation.ts')
| -rw-r--r-- | db/schema/evaluation.ts | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/db/schema/evaluation.ts b/db/schema/evaluation.ts index 4db3a25a..fd27ec9b 100644 --- a/db/schema/evaluation.ts +++ b/db/schema/evaluation.ts @@ -1,6 +1,7 @@ import { pgView , pgTable, serial, varchar, text, timestamp, integer, decimal, boolean, uuid } from 'drizzle-orm/pg-core'; import { relations , sql} from 'drizzle-orm'; import { Vendor, vendors } from './vendors'; +import { evaluationTargets, periodicEvaluations } from './evaluationTarget'; // 1. 일반 평가표 테이블 export const generalEvaluations = pgTable('general_evaluations', { @@ -145,6 +146,9 @@ export type EsgEvaluationsView = typeof esgEvaluationsView.$inferSelect; export const evaluationSubmissions = pgTable('evaluation_submissions', { id: serial('id').primaryKey(), submissionId: uuid('submission_id').defaultRandom().notNull().unique(), + periodicEvaluationId: integer('periodic_evaluation_id') + .references(() => periodicEvaluations.id, { onDelete: 'cascade' }) + .notNull(), companyId: integer('company_id').references(() => vendors.id, { onDelete: 'cascade' }).notNull(), evaluationYear: integer('evaluation_year').notNull(), evaluationRound: varchar('evaluation_round', { length: 50 }), @@ -226,6 +230,10 @@ export const evaluationSubmissionsRelations = relations(evaluationSubmissions, ( fields: [evaluationSubmissions.companyId], references: [vendors.id], }), + periodicEvaluation: one(periodicEvaluations, { + fields: [evaluationSubmissions.periodicEvaluationId], + references: [periodicEvaluations.id], + }), generalEvaluationResponses: many(generalEvaluationResponses), esgEvaluationResponses: many(esgEvaluationResponses), vendorEvaluationAttachments: many(vendorEvaluationAttachments), @@ -311,4 +319,12 @@ export type EsgEvaluationResponseWithDetails = EsgEvaluationResponse & { esgEvaluation: EsgEvaluation; }; esgAnswerOption: EsgAnswerOption; -};
\ No newline at end of file +}; + +export const periodicEvaluationsRelations = relations(periodicEvaluations, ({ many, one }) => ({ + evaluationSubmissions: many(evaluationSubmissions), + evaluationTarget: one(evaluationTargets, { + fields: [periodicEvaluations.evaluationTargetId], + references: [evaluationTargets.id], + }), +}));
\ No newline at end of file |
