mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-19 11:41:23 +02:00
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import {
|
|
pgTable,
|
|
uuid,
|
|
date,
|
|
integer,
|
|
decimal,
|
|
text,
|
|
timestamp,
|
|
index,
|
|
unique,
|
|
} from 'drizzle-orm/pg-core';
|
|
|
|
export const dailyProgress = pgTable(
|
|
'daily_progress',
|
|
{
|
|
id: uuid('id').primaryKey().defaultRandom(),
|
|
userId: uuid('user_id').notNull(),
|
|
date: date('date').notNull(),
|
|
cardsStudied: integer('cards_studied').default(0).notNull(),
|
|
timeSpentMinutes: integer('time_spent_minutes').default(0).notNull(),
|
|
accuracyPercentage: decimal('accuracy_percentage', { precision: 5, scale: 2 }).default('0').notNull(),
|
|
decksStudied: text('decks_studied').array().default([]),
|
|
sessionsCompleted: integer('sessions_completed').default(0).notNull(),
|
|
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
|
|
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
|
|
},
|
|
(table) => [
|
|
index('idx_daily_progress_user_id').on(table.userId),
|
|
index('idx_daily_progress_date').on(table.date),
|
|
unique('unique_user_date').on(table.userId, table.date),
|
|
]
|
|
);
|
|
|
|
export type DailyProgress = typeof dailyProgress.$inferSelect;
|
|
export type NewDailyProgress = typeof dailyProgress.$inferInsert;
|