Untitled

 avatar
unknown
javascript
18 days ago
2.8 kB
10
Indexable
import { pgTable, serial, text, integer, boolean } from 'drizzle-orm/pg-core';
import { sql } from 'drizzle-orm';

// Waitlist table
export const waitlistTable = pgTable('waitlist', {
  id: serial('id').primaryKey(),
  email: text('email').notNull().unique(),
  createdAt: text('created_at').default(sql`CURRENT_TIMESTAMP`).notNull(), // Fix default value to store actual timestamp
});

// Interviews table
export const interviewsTable = pgTable('interviews', {
  id: serial('id').primaryKey(),
  company: text('company').notNull(),
  interviewDate: text('interview_date').notNull(),
  createdAt: text('created_at').default(sql`CURRENT_TIMESTAMP`).notNull(),
  updatedAt: text('updated_at')
    .default(sql`CURRENT_TIMESTAMP`)
    .notNull()
    .$onUpdate(() => sql`CURRENT_TIMESTAMP`),
  overallExperience: text('overall_experience'),
  jobOffer: boolean('job_offer').default(false),
  level: text('level').default('Not Provided Yet').notNull(),
  role: text('role').default('Not Provided').notNull(), // New required field
});

// Rounds table
export const roundsTable = pgTable('rounds', {
  id: serial('id').primaryKey(),
  interviewId: integer('interview_id')
    .references(() => interviewsTable.id, { onDelete: 'cascade' }),
  roundType: text('round_type').notNull(),
  roundDate: text('round_date').notNull(),
  experience: text('experience'),
});

// Ratings table
export const ratingsTable = pgTable('ratings', {
  id: serial('id').primaryKey(),
  interviewId: integer('interview_id')
    .references(() => interviewsTable.id, { onDelete: 'cascade' }),
  category: text('category').notNull(),
  score: integer('score').notNull(),
});

// Questions table
export const questionsTable = pgTable('questions', {
  id: serial('id').primaryKey(),
  interviewId: integer('interview_id')
    .references(() => interviewsTable.id, { onDelete: 'cascade' }),
  type: text('type').notNull(),
  question: text('question').notNull(),
  leetcodeLink: text('leetcode_link'),
});

// Type inference for waitlist
export type InsertWaitlist = typeof waitlistTable.$inferInsert;
export type SelectWaitlist = typeof waitlistTable.$inferSelect;

// Type inference for interviews
export type InsertInterview = typeof interviewsTable.$inferInsert;
export type SelectInterview = typeof interviewsTable.$inferSelect;

// Type inference for rounds
export type InsertRound = typeof roundsTable.$inferInsert;
export type SelectRound = typeof roundsTable.$inferSelect;

// Type inference for ratings
export type InsertRating = typeof ratingsTable.$inferInsert;
export type SelectRating = typeof ratingsTable.$inferSelect;

// Type inference for questions
export type InsertQuestion = typeof questionsTable.$inferInsert;
export type SelectQuestion = typeof questionsTable.$inferSelect;
Leave a Comment