Skip to content

Commit

Permalink
Merge pull request #14 from wizelineacademy/db-schema-addition
Browse files Browse the repository at this point in the history
db schema implemented
  • Loading branch information
Felipegonac0 authored Apr 5, 2024
2 parents a45a557 + eb9f716 commit 22ba0f9
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,67 @@ export const rulerSurveyAnswers = pgTable(
};
},
);

export const sprintSurvey = pgTable("sprint_survey", {
id: integer("sprint_survey_id").primaryKey(),
projectId: integer("project_id").references(() => project.id),
createdAt: date("created_at"),
});

export const sprintSurveyAnswerProject = pgTable(
"sprint_survey_answer_project",
{
sprintSurveyId: integer("sprint_survey_id").references(
() => sprintSurvey.id,
),
userId: integer("user_id").references(() => user.id),
questionName: varchar("question_name", { length: 8 }),
answer: integer("answer"),
},
// composite primary key on (userId, sprintSurveyId)
(table) => {
return {
pk: primaryKey({ columns: [table.userId, table.sprintSurveyId] }),
};
},
);

export const sprintSurveyAnswerCoworkers = pgTable(
"sprint_survey_answer_coworkers",
{
sprintSurveyId: integer("sprint_survey_id").references(
() => sprintSurvey.id,
),
userId: integer("user_id").references(() => user.id),
coworkerId: integer("coworker_id"),
questionName: varchar("question_name", { length: 8 }),
answer: integer("answer"),
},
// composite primary key on (userId, sprintSurveyId)
(table) => {
return {
pk: primaryKey({ columns: [table.userId, table.sprintSurveyId] }),
};
},
);

export const finalSurvey = pgTable("final_survey", {
id: integer("final_survey_id").primaryKey(),
created_at: date("created_at"),
projectId: integer("project_id").references(() => project.id),
});

export const finalSurveyAnswer = pgTable(
"final_survey_answer",
{
userId: integer("user_id").references(() => user.id),
finalSurveyId: integer("final_survey_id").references(() => finalSurvey.id),
questionName: varchar("question_name", { length: 8 }),
answer: integer("answer"),
},
(table) => {
return {
pk: primaryKey({ columns: [table.userId, table.finalSurveyId] }),
};
},
);

0 comments on commit 22ba0f9

Please sign in to comment.