mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-03-21 18:04:39 -05:00
26 lines
661 B
JavaScript
26 lines
661 B
JavaScript
export function up(db) {
|
|
db.transaction(() => {
|
|
db.prepare(/* sql */ `alter table "User" add "createdAt" integer`).run();
|
|
|
|
db.prepare(
|
|
/* sql */ `alter table "Tournament" add "isFinalized" integer not null default 0`,
|
|
).run();
|
|
|
|
const finalizedTournamentIds = db
|
|
.prepare(
|
|
/* sql */ `select "tournamentId" from "TournamentResult" group by "tournamentId"`,
|
|
)
|
|
.all();
|
|
|
|
const updateStatement = db.prepare(
|
|
/* sql */ `update "Tournament" set isFinalized = 1 where id = @tournamentId`,
|
|
);
|
|
|
|
for (const tournamentId of finalizedTournamentIds) {
|
|
updateStatement.run({
|
|
tournamentId: tournamentId.tournamentId,
|
|
});
|
|
}
|
|
})();
|
|
}
|