sendou.ink/migrations/126-pick-ban-custom-flow.js
Kalle 7300693ba9
Some checks are pending
E2E Tests / e2e (push) Waiting to run
Tests and checks on push / run-checks-and-tests (push) Waiting to run
Updates translation progress / update-translation-progress-issue (push) Waiting to run
Custom flow in pick/ban (#2923)
2026-03-29 18:00:15 +03:00

42 lines
1.3 KiB
JavaScript

export function up(db) {
db.transaction(() => {
db.prepare(
/*sql*/ `
create table "TournamentMatchPickBanEvent_new" (
"type" text not null,
"stageId" integer,
"mode" text,
"matchId" integer not null,
"authorId" integer,
"number" integer not null,
"createdAt" integer default (strftime('%s', 'now')) not null,
foreign key ("authorId") references "User"("id") on delete restrict,
foreign key ("matchId") references "TournamentMatch"("id") on delete cascade,
unique("matchId", "number") on conflict rollback
) strict
`,
).run();
db.prepare(
/*sql*/ `
insert into "TournamentMatchPickBanEvent_new" ("type", "stageId", "mode", "matchId", "authorId", "number", "createdAt")
select "type", "stageId", "mode", "matchId", "authorId", "number", "createdAt"
from "TournamentMatchPickBanEvent"
`,
).run();
db.prepare(/*sql*/ `drop table "TournamentMatchPickBanEvent"`).run();
db.prepare(
/*sql*/ `alter table "TournamentMatchPickBanEvent_new" rename to "TournamentMatchPickBanEvent"`,
).run();
db.prepare(
/*sql*/ `create index pick_ban_event_author_id on "TournamentMatchPickBanEvent"("authorId")`,
).run();
db.prepare(
/*sql*/ `create index pick_ban_event_match_id on "TournamentMatchPickBanEvent"("matchId")`,
).run();
})();
}