mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-30 07:12:36 -05:00
Add badges migration
This commit is contained in:
@@ -51,3 +51,18 @@ export interface PlusTier {
|
||||
userId: number;
|
||||
tier: number;
|
||||
}
|
||||
|
||||
export interface Badge {
|
||||
code: string;
|
||||
displayName: string;
|
||||
}
|
||||
|
||||
export interface BadgeOwner {
|
||||
code: string;
|
||||
userId: number;
|
||||
}
|
||||
|
||||
export interface BadgeManager {
|
||||
code: string;
|
||||
userId: number;
|
||||
}
|
||||
|
||||
190
migrations/001-badges.js
Normal file
190
migrations/001-badges.js
Normal file
@@ -0,0 +1,190 @@
|
||||
module.exports.up = function (db) {
|
||||
db.prepare(
|
||||
`
|
||||
create table "Badge" (
|
||||
"code" text not null primary key,
|
||||
"displayName" text not null
|
||||
) strict
|
||||
`
|
||||
).run();
|
||||
|
||||
for (const badge of initialBadgesForDb()) {
|
||||
db.prepare(
|
||||
`insert into "Badge" ("code", "displayName") values ($code, $displayName)`
|
||||
).run(badge);
|
||||
}
|
||||
|
||||
db.prepare(
|
||||
`
|
||||
create table "BadgeOwner" (
|
||||
"code" text not null,
|
||||
"userId" integer not null
|
||||
) strict
|
||||
`
|
||||
).run();
|
||||
|
||||
db.prepare(
|
||||
`
|
||||
create table "BadgeManager" (
|
||||
"code" text not null,
|
||||
"userId" integer not null,
|
||||
unique("code", "userId") on conflict rollback
|
||||
) strict
|
||||
`
|
||||
).run();
|
||||
};
|
||||
|
||||
module.exports.down = function (db) {
|
||||
db.prepare(`drop table "Badge"`).run();
|
||||
db.prepare(`drop table "BadgeOwner"`).run();
|
||||
db.prepare(`drop table "BadgeManager"`).run();
|
||||
};
|
||||
|
||||
function initialBadgesForDb() {
|
||||
return [
|
||||
{
|
||||
code: "sundae",
|
||||
displayName: "4v4 Sundaes",
|
||||
},
|
||||
{
|
||||
code: "zones",
|
||||
displayName: "Dapple SZ Speedladder",
|
||||
},
|
||||
{
|
||||
code: "ebtv",
|
||||
displayName: "EBTV League",
|
||||
},
|
||||
{
|
||||
code: "girls",
|
||||
displayName: "Girls Duo Cup",
|
||||
},
|
||||
{
|
||||
code: "idtga",
|
||||
displayName: "It's Dangerous to go Alone",
|
||||
},
|
||||
{
|
||||
code: "beta_top1",
|
||||
displayName: "Beta's Events",
|
||||
},
|
||||
{
|
||||
code: "beta_top2",
|
||||
displayName: "Launch Day",
|
||||
},
|
||||
{
|
||||
code: "beta_top3",
|
||||
displayName: "Launch Day",
|
||||
},
|
||||
{
|
||||
code: "pair",
|
||||
displayName: "League Rush (Pair)",
|
||||
},
|
||||
{
|
||||
code: "quad",
|
||||
displayName: "League Rush (Quad)",
|
||||
},
|
||||
{
|
||||
code: "lobster",
|
||||
displayName: "Lobster Crossfire",
|
||||
},
|
||||
{
|
||||
code: "monday",
|
||||
displayName: "Monday Afterparty",
|
||||
},
|
||||
{
|
||||
code: "pool1",
|
||||
displayName: "Paddling Pool Weekly",
|
||||
},
|
||||
{
|
||||
code: "snapshot_gold",
|
||||
displayName: "Snapshot (Alpha)",
|
||||
},
|
||||
{
|
||||
code: "snapshot_silver",
|
||||
displayName: "Snapshot (Beta)",
|
||||
},
|
||||
{
|
||||
code: "snapshot_bronze",
|
||||
displayName: "Snapshot (Gamma)",
|
||||
},
|
||||
{
|
||||
code: "superjump_alpha",
|
||||
displayName: "Superjump",
|
||||
},
|
||||
{
|
||||
code: "superjump_beta",
|
||||
displayName: "Superjump (Beta bracket)",
|
||||
},
|
||||
{
|
||||
code: "superjump_gamma",
|
||||
displayName: "Superjump (Gamma bracket)",
|
||||
},
|
||||
{
|
||||
code: "toni_kensa",
|
||||
displayName: "Toni Kensa Cup",
|
||||
},
|
||||
{
|
||||
code: "pool2",
|
||||
displayName: "Golden Paddling Pool Event",
|
||||
},
|
||||
{
|
||||
code: "lutipink",
|
||||
displayName: "LUTI Season 12 (Div X)",
|
||||
},
|
||||
{
|
||||
code: "lutired",
|
||||
displayName: "LUTI Season 12 (Div 1)",
|
||||
},
|
||||
{
|
||||
code: "lutiorange",
|
||||
displayName: "LUTI Season 12 (Div 2)",
|
||||
},
|
||||
{
|
||||
code: "lutiyellow",
|
||||
displayName: "LUTI Season 12 (Div 3)",
|
||||
},
|
||||
{
|
||||
code: "lutilimegreen",
|
||||
displayName: "LUTI Season 12 (Div 4)",
|
||||
},
|
||||
{
|
||||
code: "lutigreen",
|
||||
displayName: "LUTI Season 12 (Div 5)",
|
||||
},
|
||||
{
|
||||
code: "lutiblue",
|
||||
displayName: "LUTI Season 12 (Div 6)",
|
||||
},
|
||||
{
|
||||
code: "lutipurple",
|
||||
displayName: "LUTI Season 12 (Div 7)",
|
||||
},
|
||||
{
|
||||
code: "lutitan",
|
||||
displayName: "LUTI Season 12 (Div 8)",
|
||||
},
|
||||
{
|
||||
code: "lutitan2",
|
||||
displayName: "LUTI Season 12 (Div 9)",
|
||||
},
|
||||
{
|
||||
code: "tidal_tuesdays",
|
||||
displayName: "Tidal Tuesdays",
|
||||
},
|
||||
{
|
||||
code: "squid_junction",
|
||||
displayName: "Squid Junction",
|
||||
},
|
||||
{
|
||||
code: "triton",
|
||||
displayName: "Triton-Cup",
|
||||
},
|
||||
{
|
||||
code: "cake",
|
||||
displayName: "Yay's SUPER AWESOME Birthday Bash!",
|
||||
},
|
||||
{
|
||||
code: "20xx",
|
||||
displayName: "a 20XX Series tournament",
|
||||
},
|
||||
];
|
||||
}
|
||||
229
scripts/badges.mjs
Normal file
229
scripts/badges.mjs
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user