test(channelserver): add comprehensive GuildRepository tests

Add 34 tests covering all previously-untested GuildRepository methods:
invitations/scouts, guild posts, alliances, adventures, treasure
hunts, meals, kill tracking, and edge cases like disband with
alliance cleanup.

Fix test schema setup to apply the 9.2 update schema after init.sql,
which bridges v9.1.0 to v9.2.0 and resolves 9 pre-existing test
failures caused by missing columns (rp_today, created_at, etc.).

Make patch schemas 14 and 19 idempotent so they no longer fail when
applied against a schema that already has the target state (e.g.
festival_color type already renamed, legacy column names).
This commit is contained in:
Houmgaor
2026-02-20 22:53:16 +01:00
parent 93f28c721a
commit 7436ac0870
4 changed files with 980 additions and 18 deletions

View File

@@ -1,11 +1,20 @@
BEGIN;
DELETE FROM public.fpoint_items;
ALTER TABLE IF EXISTS public.fpoint_items ALTER COLUMN item_type SET NOT NULL;
ALTER TABLE IF EXISTS public.fpoint_items ALTER COLUMN item_id SET NOT NULL;
ALTER TABLE IF EXISTS public.fpoint_items ALTER COLUMN quantity SET NOT NULL;
ALTER TABLE IF EXISTS public.fpoint_items ALTER COLUMN fpoints SET NOT NULL;
ALTER TABLE IF EXISTS public.fpoint_items DROP COLUMN IF EXISTS trade_type;
ALTER TABLE IF EXISTS public.fpoint_items ADD COLUMN buyable boolean NOT NULL;
END;
DO $$ BEGIN
-- Only apply if the new-schema columns exist (item_type vs legacy itemtype)
IF EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name='fpoint_items' AND column_name='item_type'
) THEN
DELETE FROM public.fpoint_items;
ALTER TABLE public.fpoint_items ALTER COLUMN item_type SET NOT NULL;
ALTER TABLE public.fpoint_items ALTER COLUMN item_id SET NOT NULL;
ALTER TABLE public.fpoint_items ALTER COLUMN quantity SET NOT NULL;
ALTER TABLE public.fpoint_items ALTER COLUMN fpoints SET NOT NULL;
ALTER TABLE public.fpoint_items DROP COLUMN IF EXISTS trade_type;
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name='fpoint_items' AND column_name='buyable'
) THEN
ALTER TABLE public.fpoint_items ADD COLUMN buyable boolean NOT NULL DEFAULT false;
END IF;
END IF;
END $$;

View File

@@ -1,6 +1,4 @@
BEGIN;
CREATE TABLE festa_submissions (
CREATE TABLE IF NOT EXISTS festa_submissions (
character_id int NOT NULL,
guild_id int NOT NULL,
trial_type int NOT NULL,
@@ -8,8 +6,11 @@ CREATE TABLE festa_submissions (
timestamp timestamp with time zone NOT NULL
);
ALTER TABLE guild_characters DROP COLUMN souls;
ALTER TABLE guild_characters DROP COLUMN IF EXISTS souls;
ALTER TYPE festival_colour RENAME TO festival_color;
END;
DO $$ BEGIN
ALTER TYPE festival_colour RENAME TO festival_color;
EXCEPTION
WHEN undefined_object THEN NULL;
WHEN duplicate_object THEN NULL;
END $$;