mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-17 12:49:40 +02:00
Applied formatting to 1487+ files using pnpm format:write - TypeScript/JavaScript files - Svelte components - Astro pages - JSON configs - Markdown docs 13 files still need manual review (Astro JSX comments)
48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
import {
|
|
pgTable,
|
|
uuid,
|
|
varchar,
|
|
text,
|
|
boolean,
|
|
timestamp,
|
|
jsonb,
|
|
index,
|
|
} from 'drizzle-orm/pg-core';
|
|
import { relations } from 'drizzle-orm';
|
|
import { cards } from './cards.js';
|
|
import { studySessions } from './studySessions.js';
|
|
import { aiGenerations } from './aiGenerations.js';
|
|
|
|
export const decks = pgTable(
|
|
'decks',
|
|
{
|
|
id: uuid('id').primaryKey().defaultRandom(),
|
|
userId: uuid('user_id').notNull(),
|
|
title: varchar('title', { length: 255 }).notNull(),
|
|
description: text('description'),
|
|
coverImageUrl: text('cover_image_url'),
|
|
isPublic: boolean('is_public').default(false).notNull(),
|
|
isFeatured: boolean('is_featured').default(false).notNull(),
|
|
featuredAt: timestamp('featured_at', { withTimezone: true }),
|
|
settings: jsonb('settings').default({}).$type<Record<string, unknown>>(),
|
|
tags: text('tags').array().default([]),
|
|
metadata: jsonb('metadata').default({}).$type<Record<string, unknown>>(),
|
|
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
|
|
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
|
|
},
|
|
(table) => [
|
|
index('idx_decks_user_id').on(table.userId),
|
|
index('idx_decks_is_public').on(table.isPublic),
|
|
index('idx_decks_is_featured').on(table.isFeatured),
|
|
index('idx_decks_updated_at').on(table.updatedAt),
|
|
]
|
|
);
|
|
|
|
export const decksRelations = relations(decks, ({ many }) => ({
|
|
cards: many(cards),
|
|
studySessions: many(studySessions),
|
|
aiGenerations: many(aiGenerations),
|
|
}));
|
|
|
|
export type Deck = typeof decks.$inferSelect;
|
|
export type NewDeck = typeof decks.$inferInsert;
|