sendou.ink/migrations/065-tournament-orgs.js
Kalle 9312fad90f
Tournament organization page (#1811)
* Initial

* Calendar initial

* Extract EventCalendar

* Events list initial

* Winners

* SQL fixes

* List events by series

* Leaderboards

* Series leaderboard

* Own entry peek

* Edit page skeleton

* RHF initial test

* RHF stuff

* Form etc. progress

* Fix tournament series description

* Fix tabs layout

* Fix socials insert

* Check for not removing admin

* Adding series

* TODOs

* Allow updating org with no series

* FormFieldset

* Allow series without events

* TextAreaFormfield accepting array syntax

* Input form array field

* ToggleFormField

* SelectFormField

* UserSearchFormField

* Fetch badgeOptions

* Badge editing

* Progress

* Use native preventScrollReset

* Rename func

* Fix sticky scroll

* Fix translation

* i18n errors

* handle,meta in edit

* Add ref to user search

* TODOs

* Done
2024-07-25 23:06:29 +03:00

73 lines
2.3 KiB
JavaScript

export function up(db) {
db.transaction(() => {
db.prepare(
/*sql*/ `
create table "TournamentOrganization" (
"id" integer primary key,
"name" text not null,
"slug" text unique not null,
"description" text,
"socials" text,
"avatarImgId" integer,
foreign key ("avatarImgId") references "UnvalidatedUserSubmittedImage"("id") on delete set null
) strict
`,
).run();
db.prepare(
/*sql*/ `create index tournament_organization_slug on "TournamentOrganization"("slug")`,
).run();
db.prepare(
/*sql*/ `
create table "TournamentOrganizationMember" (
"organizationId" integer not null,
"userId" integer not null,
"role" text not null,
"roleDisplayName" text,
foreign key ("organizationId") references "TournamentOrganization"("id") on delete cascade,
foreign key ("userId") references "User"("id") on delete cascade,
unique("organizationId", "userId") on conflict rollback
) strict
`,
).run();
db.prepare(
/*sql*/ `
create table "TournamentOrganizationBadge" (
"organizationId" integer not null,
"badgeId" integer not null,
foreign key ("organizationId") references "TournamentOrganization"("id") on delete cascade,
foreign key ("badgeId") references "Badge"("id") on delete cascade,
unique("organizationId", "badgeId") on conflict rollback
) strict
`,
).run();
db.prepare(
/*sql*/ `
create table "TournamentOrganizationSeries" (
"id" integer primary key,
"organizationId" integer not null,
"name" text not null,
"description" text,
"substringMatches" text not null,
"showLeaderboard" integer not null default 0,
foreign key ("organizationId") references "TournamentOrganization"("id") on delete cascade
) strict
`,
).run();
db.prepare(
/*sql*/ `create index tournament_organization_series_organization_id on "TournamentOrganizationSeries"("organizationId")`,
).run();
db.prepare(
/* sql */ `alter table "CalendarEvent" add "organizationId" integer references "TournamentOrganization"("id") on delete set null`,
).run();
db.prepare(
/*sql*/ `create index calendar_event_organization_id on "CalendarEvent"("organizationId")`,
).run();
})();
}