From 36cddaa5ec5fa3952cba5f32cf4cc7d9ecfb3c65 Mon Sep 17 00:00:00 2001 From: xangelo Date: Mon, 10 Jul 2023 15:13:46 -0400 Subject: [PATCH] refactor: remove unused requirements/boost columns When we migrated to json column types for boosts/requirements, we had to leave the old columns in for a smooth migration (no data loss). This migration removes that. --- migrations/20230710191035_boost-cleanup.ts | 27 ++++++++++++++++++++++ src/server/equipment.ts | 11 ++------- src/server/shopItem.ts | 4 ++-- 3 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 migrations/20230710191035_boost-cleanup.ts diff --git a/migrations/20230710191035_boost-cleanup.ts b/migrations/20230710191035_boost-cleanup.ts new file mode 100644 index 0000000..75d8fff --- /dev/null +++ b/migrations/20230710191035_boost-cleanup.ts @@ -0,0 +1,27 @@ +import { Knex } from "knex"; + + +export async function up(knex: Knex): Promise { + return knex.schema.alterTable('inventory', function(table) { + ['strength','dexterity','intelligence','constitution'].forEach(s => { + table.dropColumn(`boost_${s}`); + table.dropColumn(`requirement_${s}`); + }); + + table.dropColumn('boost_damage'); + table.dropColumn('requirement_level'); + }).alterTable('shop_items', function(table) { + ['strength','dexterity','intelligence','constitution'].forEach(s => { + table.dropColumn(`boost_${s}`); + table.dropColumn(`requirement_${s}`); + }); + + table.dropColumn('boost_damage'); + table.dropColumn('requirement_level'); + }); +} + + +export async function down(knex: Knex): Promise { +} + diff --git a/src/server/equipment.ts b/src/server/equipment.ts index ad34640..9ebac7d 100644 --- a/src/server/equipment.ts +++ b/src/server/equipment.ts @@ -10,16 +10,9 @@ export async function getEquippedItems(playerId: string): Promise): Promise { return db.select('*').from('shop_items') .where(where) - .orderBy('requirement_level') .orderBy('type') - .orderBy('equipment_slot'); + .orderBy('equipment_slot') + .orderByRaw(`requirements->>'level' asc`); } export function getShopItem(id: number): Promise { -- 2.25.1