mirror of
https://github.com/nestriness/nestri.git
synced 2026-09-23 11:08:18 +03:00
feat: Sync to OSS repo
This commit is contained in:
38
packages/core/src/game/download.sql.ts
Normal file
38
packages/core/src/game/download.sql.ts
Normal 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)
|
||||
]
|
||||
);
|
||||
Reference in New Issue
Block a user