import { pgTable, uuid, text, jsonb, timestamp } from 'drizzle-orm/pg-core'; import type { ScoreboardState } from '@sbt/shared'; export const users = pgTable('users', { id: uuid('id').primaryKey().defaultRandom(), email: text('email').notNull().unique(), passwordHash: text('password_hash').notNull(), createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(), }); export const scoreboards = pgTable('scoreboards', { id: uuid('id').primaryKey().defaultRandom(), ownerId: uuid('owner_id') .notNull() .references(() => users.id, { onDelete: 'cascade' }), name: text('name').notNull(), state: jsonb('state').$type().notNull(), overlayToken: text('overlay_token').notNull().unique(), controlToken: text('control_token').notNull().unique(), createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(), updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(), });