fix: migration runner idempotente e seeds com UNIQUE constraint

Runner agora checa schema_migrations antes de rodar cada SQL — sem
reexecução de seeds a cada startup. Quests: UNIQUE(title, quest_type).
Cosmetics: UNIQUE(name), tipos corrigidos para hair/shirt/pants/shoes.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
2026-05-26 22:01:48 -03:00
co-authored by Claude Sonnet 4.6
parent c1964ea036
commit 2277f4375d
3 changed files with 29 additions and 12 deletions
@@ -6,7 +6,8 @@ CREATE TABLE IF NOT EXISTS quests (
target_count INTEGER,
target_pct NUMERIC(5,2),
xp_reward INTEGER NOT NULL DEFAULT 50,
active BOOLEAN NOT NULL DEFAULT TRUE
active BOOLEAN NOT NULL DEFAULT TRUE,
UNIQUE (title, quest_type)
);
CREATE TABLE IF NOT EXISTS player_quests (
@@ -27,6 +28,6 @@ INSERT INTO quests (title, description, quest_type, target_count, target_pct, xp
('Categorizador Ativo', 'Categorize 5 transações hoje', 'daily', 5, NULL, 30),
('Controlador Semanal', 'Registre ao menos 3 transações esta semana', 'weekly', 3, NULL, 40),
('Mês Sem Surpresas', 'Cubra todas as recorrências do mês', 'monthly', NULL, NULL, 150)
ON CONFLICT DO NOTHING;
ON CONFLICT (title, quest_type) DO NOTHING;
INSERT INTO schema_migrations (version) VALUES (6) ON CONFLICT DO NOTHING;