-- 000006a: enemy archetypes column, quest targets, clear enemies before bulk insert.
-- Full chain: 000006a_head -> 000006b_enemy_data -> 000006c_tail (lexicographic order).

ALTER TABLE public.enemies ADD COLUMN IF NOT EXISTS archetype text;

ALTER TABLE public.enemies ADD COLUMN IF NOT EXISTS biome text;

UPDATE public.enemies SET archetype = type WHERE (archetype IS NULL OR archetype = '') AND type IS NOT NULL;

ALTER TABLE public.quests ADD COLUMN IF NOT EXISTS target_enemy_archetype text;

UPDATE public.quests
SET target_enemy_archetype = target_enemy_type
WHERE target_enemy_type IS NOT NULL AND target_enemy_archetype IS NULL;

UPDATE public.quests SET target_enemy_type = NULL WHERE target_enemy_archetype IS NOT NULL;

DELETE FROM public.enemies;
