This commit is contained in:
@@ -17,6 +17,7 @@ import { migrateHostSchema } from '../hosts/schema.js';
|
||||
import { migrateAuthSchema, migrateSuperViewerRole } from '../auth/schema.js';
|
||||
import { migrateGameFileSchema } from '../game-files/schema.js';
|
||||
import { migrateLeaderboardReports } from './leaderboard-reports.js';
|
||||
import { migratePlayerScoreTotal } from './player-score-total.js';
|
||||
import type { Migration } from './migration-runner.js';
|
||||
|
||||
// Append only: never renumber entries or change an applied migration to add an
|
||||
@@ -103,6 +104,11 @@ export const migrations: readonly Migration[] = [
|
||||
version: 18,
|
||||
name: 'durable leaderboard report identity and sequences',
|
||||
run: migrateLeaderboardReports
|
||||
},
|
||||
{
|
||||
version: 19,
|
||||
name: 'cumulative player score per match',
|
||||
run: migratePlayerScoreTotal
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import type Database from 'better-sqlite3';
|
||||
|
||||
/** Old score balances cannot be used to reconstruct cumulative points. */
|
||||
export function migratePlayerScoreTotal(handle: Database.Database): void {
|
||||
const columns = handle.prepare('PRAGMA table_info(leaderboard_match_players)').all() as {
|
||||
name: string;
|
||||
}[];
|
||||
if (!columns.some((column) => column.name === 'score_total'))
|
||||
handle.exec(`ALTER TABLE leaderboard_match_players ADD COLUMN score_total INTEGER
|
||||
CHECK (score_total IS NULL OR (typeof(score_total) = 'integer' AND score_total >= 0))`);
|
||||
}
|
||||
Reference in New Issue
Block a user