mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-26 01:09:02 -05:00
36 lines
811 B
JavaScript
36 lines
811 B
JavaScript
export function up(db) {
|
|
db.transaction(() => {
|
|
const roundsWithNullMaps = db
|
|
.prepare(
|
|
/* sql */ `select "id" from "TournamentRound" where "maps" is null`,
|
|
)
|
|
.all()
|
|
.map((row) => row.id);
|
|
|
|
for (const roundId of roundsWithNullMaps) {
|
|
const count = db
|
|
.prepare(
|
|
/* sql */ `select "bestOf" from "TournamentMatch" where "roundId" = @roundId`,
|
|
)
|
|
.get({ roundId }).bestOf;
|
|
|
|
db.prepare(
|
|
/* sql */ `update "TournamentRound" set "maps" = @maps where "id" = @id`,
|
|
).run({
|
|
id: roundId,
|
|
maps: JSON.stringify({
|
|
type: "BEST_OF",
|
|
count,
|
|
}),
|
|
});
|
|
}
|
|
|
|
db.prepare(
|
|
/* sql */ `alter table "TournamentMatch" drop column "bestOf"`,
|
|
).run();
|
|
db.prepare(
|
|
/* sql */ `alter table "CalendarEvent" drop column "avatarMetadata"`,
|
|
).run();
|
|
})();
|
|
}
|