feat: add tests and test_questions schema
Made-with: Cursor
This commit is contained in:
22
src/db/schema/tests.ts
Normal file
22
src/db/schema/tests.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { pgTable, uuid, integer, timestamp } from 'drizzle-orm/pg-core';
|
||||
import { stackEnum, levelEnum, testModeEnum, testStatusEnum } from './enums.js';
|
||||
import { users } from './users.js';
|
||||
|
||||
export const tests = pgTable('tests', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
userId: uuid('user_id')
|
||||
.notNull()
|
||||
.references(() => users.id, { onDelete: 'cascade' }),
|
||||
stack: stackEnum('stack').notNull(),
|
||||
level: levelEnum('level').notNull(),
|
||||
questionCount: integer('question_count').notNull(),
|
||||
mode: testModeEnum('mode').notNull().default('fixed'),
|
||||
status: testStatusEnum('status').notNull().default('in_progress'),
|
||||
score: integer('score'),
|
||||
startedAt: timestamp('started_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
finishedAt: timestamp('finished_at', { withTimezone: true }),
|
||||
timeLimitSeconds: integer('time_limit_seconds'),
|
||||
});
|
||||
|
||||
export type Test = typeof tests.$inferSelect;
|
||||
export type NewTest = typeof tests.$inferInsert;
|
||||
Reference in New Issue
Block a user