feat: Sync to OSS repo

This commit is contained in:
Wanjohi
2026-08-06 22:13:51 +03:00
parent 46d2a56180
commit 3faac3008f
144 changed files with 27561 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
import { bigint, index, pgEnum, pgTable, text, uniqueIndex } from 'drizzle-orm/pg-core';
import { id, timestamps, ulid, utc } from '../db/types.js';
import { GameTable } from './game.sql.js';
export const GameDownloadStatus = pgEnum('game_download_status', [
'pending',
'verifying',
'downloading',
'ready',
'failed'
]);
export const GameDownloadTable = pgTable(
'game_download',
{
...id,
...timestamps,
hostId: text('host_id').notNull(),
gameId: ulid('game_id')
.notNull()
.references(() => GameTable.id, { onDelete: 'cascade' }),
status: GameDownloadStatus('status').notNull().default('pending'),
progressBytes: bigint('progress_bytes', { mode: 'number' }).default(0),
totalBytes: bigint('total_bytes', { mode: 'number' }),
timeStarted: utc('time_started'),
timeCompleted: utc('time_completed'),
errorMessage: text('error_message')
},
(t) => [
uniqueIndex('game_download_host_game_unique').on(t.hostId, t.gameId),
index('game_download_game_idx').on(t.gameId),
index('game_download_host_status_idx').on(t.hostId, t.status)
]
);