Files
samreshu_backend/src/db/schema/tests.ts
2026-03-04 13:38:19 +03:00

23 lines
962 B
TypeScript

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;