From 5dcc1082878247212eb4624e0b411a1a343005ff Mon Sep 17 00:00:00 2001 From: legonzaur Date: Mon, 24 Apr 2023 21:15:21 +0200 Subject: [PATCH] Patch weapon mods --- .../2023-04-24-01 Offhand weapons patch.ts | 42 +++++++++++++++++++ src/server/server.ts | 6 +++ 2 files changed, 48 insertions(+) create mode 100644 src/db/migrations/2023-04-24-01 Offhand weapons patch.ts diff --git a/src/db/migrations/2023-04-24-01 Offhand weapons patch.ts b/src/db/migrations/2023-04-24-01 Offhand weapons patch.ts new file mode 100644 index 0000000..e8a9b77 --- /dev/null +++ b/src/db/migrations/2023-04-24-01 Offhand weapons patch.ts @@ -0,0 +1,42 @@ +import { Kysely, sql } from 'kysely' +import { Client } from 'pg' + +const pgClient = new Client({ + host: process.env.POSTGRES_HOST, + database: process.env.POSTGRES_DATABASE, + user: process.env.POSTGRES_USER, + password: process.env.POSTGRES_PASSWORD +}) + +export async function up(db: Kysely): Promise { + await pgClient.connect() + await pgClient.query( + `ALTER TABLE kill RENAME attacker_offhand_weapon_3 TO victim_offhand_weapon_3_mods;` + ) + await pgClient.query( + `ALTER TABLE kill RENAME attacker_offhand_weapon_2 TO victim_offhand_weapon_2_mods;` + ) + await pgClient.query( + `ALTER TABLE kill RENAME attacker_offhand_weapon_1 TO victim_offhand_weapon_1_mods;` + ) + await pgClient.query( + `ALTER TABLE kill RENAME victim_offhand_weapon_3 TO victim_offhand_weapon_3_mods;` + ) + await pgClient.query( + `ALTER TABLE kill RENAME victim_offhand_weapon_2 TO victim_offhand_weapon_2_mods;` + ) + await pgClient.query( + `ALTER TABLE kill RENAME victim_offhand_weapon_1 TO victim_offhand_weapon_1_mods;` + ) + + await pgClient.query(`ALTER TABLE kill ADD COLUMN IF NOT EXISTS victim_offhand_weapon_1 character varying NULL;`) + await pgClient.query(`ALTER TABLE kill ADD COLUMN IF NOT EXISTS victim_offhand_weapon_2 character varying NULL;`) + await pgClient.query(`ALTER TABLE kill ADD COLUMN IF NOT EXISTS victim_offhand_weapon_3 character varying NULL;`) + await pgClient.query(`ALTER TABLE kill ADD COLUMN IF NOT EXISTS attacker_offhand_weapon_1 character varying NULL;`) + await pgClient.query(`ALTER TABLE kill ADD COLUMN IF NOT EXISTS attacker_offhand_weapon_2 character varying NULL;`) + await pgClient.query(`ALTER TABLE kill ADD COLUMN IF NOT EXISTS attacker_offhand_weapon_3 character varying NULL;`) + //Update the hosts column once the hoster table is manually updated + await pgClient.end() +} + +export async function down(db: Kysely): Promise { } diff --git a/src/server/server.ts b/src/server/server.ts index 1e6ca69..d742446 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -107,13 +107,19 @@ router.post( 'attacker_name', 'attacker_current_weapon', 'attacker_weapon_1', + 'attacker_weapon_1_mods', 'attacker_weapon_2', + 'attacker_weapon_2_mods', 'attacker_weapon_3', + 'attacker_weapon_3_mods', 'victim_name', 'victim_current_weapon', 'victim_weapon_1', + 'victim_weapon_1_mods', 'victim_weapon_2', + 'victim_weapon_2_mods', 'victim_weapon_3', + 'victim_weapon_3_mods', 'cause_of_death', 'victim_titan', 'attacker_titan'