feat(db): add embedded auto-migrating schema system

Replace 4 independent schema management code paths (Docker shell
script, setup wizard pg_restore, test helpers, manual psql) with a
single migration runner embedded in the server binary.

The new server/migrations/ package uses Go embed to bundle all SQL
schemas. On startup, Migrate() creates a schema_version tracking
table, detects existing databases (auto-marks baseline as applied),
and runs pending migrations in transactions.

Key changes:
- Consolidated init.sql + 9.2-update + 33 patches into 0001_init.sql
- Setup wizard simplified to single "Apply schema" checkbox
- Test helpers use migrations.Migrate() instead of pg_restore
- Docker no longer needs schema volume mounts or init script
- Seed data (shops, events, gacha) embedded and applied via API
- Future migrations just add 0002_*.sql files — no manual steps
This commit is contained in:
Houmgaor
2026-02-23 21:19:21 +01:00
parent 6a7db47723
commit 27fb0faa1e
62 changed files with 4736 additions and 932 deletions

View File

@@ -0,0 +1,292 @@
BEGIN;
-- Ripped quests
INSERT INTO public.event_quests (max_players, quest_type, quest_id, mark) VALUES
(0,9,40060,0),
(0,9,40079,0),
(0,9,40080,0),
(0,9,40081,0),
(0,9,40133,0),
(0,9,40134,0),
(0,9,40135,0),
(0,9,40136,0),
(0,9,40137,0),
(0,9,40138,0),
(0,9,40142,0),
(0,9,40143,0),
(0,9,40161,0),
(0,9,40162,0),
(4,9,40173,0),
(4,9,40174,0),
(0,9,40201,0),
(0,9,40218,0),
(4,43,40236,1),
(4,28,40241,1),
(0,8,50534,0),
(4,18,50852,1),
(4,18,50940,1),
(4,18,51024,1),
(4,18,51025,1),
(4,18,51026,1),
(4,18,51027,1),
(4,38,51052,9),
(4,38,51053,9),
(4,18,51059,1),
(4,38,51107,9),
(4,24,51125,0),
(1,24,51126,0),
(4,24,51127,0),
(4,24,51128,0),
(4,24,51129,0),
(4,26,53034,1),
(4,18,53140,1),
(4,18,53187,1),
(4,18,53201,1),
(1,18,53253,1),
(4,26,53307,1),
(4,24,53314,0),
(4,24,53315,0),
(4,24,53316,0),
(4,24,53317,0),
(4,24,53318,0),
(4,24,53319,0),
(4,24,53320,0),
(4,24,53321,0),
(4,24,53324,0),
(1,18,53326,2),
(4,31,54244,0),
(0,8,54425,0),
(4,28,54449,1),
(4,28,54593,1),
(4,28,54594,1),
(4,28,54603,1),
(4,28,54604,1),
(4,28,54605,1),
(4,28,54606,1),
(1,28,54608,0),
(1,28,54609,0),
(32,40,54751,0),
(32,40,54752,0),
(32,40,54753,0),
(32,40,54754,0),
(32,40,54755,0),
(32,40,54756,0),
(32,40,54757,0),
(32,40,54758,0),
(32,40,54759,0),
(32,40,54760,0),
(32,40,54761,0),
(4,28,54801,0),
(4,28,55002,1),
(4,28,55195,0),
(4,28,55202,0),
(4,28,55203,0),
(4,28,55204,0),
(0,8,55369,0),
(4,28,55464,1),
(4,43,55513,1),
(4,28,55529,0),
(4,28,55532,0),
(1,28,55536,0),
(1,28,55537,0),
(32,50,55596,0),
(32,50,55597,0),
(32,50,55598,0),
(32,50,55599,0),
(32,50,55601,0),
(32,50,55602,0),
(32,50,55603,0),
(32,50,55604,0),
(32,50,55605,0),
(32,50,55606,0),
(32,50,55607,0),
(4,28,55619,0),
(4,28,55670,1),
(4,39,55679,9),
(4,39,55680,9),
(4,43,55691,1),
(4,43,55692,1),
(4,43,55693,1),
(4,43,55694,1),
(4,43,55695,1),
(4,43,55696,1),
(4,43,55697,1),
(4,43,55698,1),
(1,43,55728,1),
(4,43,55738,1),
(0,8,55767,0),
(0,8,55768,0),
(4,28,55771,1),
(4,39,55772,9),
(8,51,55796,0),
(8,51,55797,0),
(8,51,55798,0),
(8,51,55799,0),
(8,51,55801,0),
(8,51,55802,0),
(8,51,55803,0),
(8,51,55804,0),
(8,51,55805,0),
(8,51,55806,0),
(8,51,55807,0),
(1,28,55808,0),
(0,8,55870,0),
(0,8,55872,0),
(0,8,55879,0),
(0,8,55880,0),
(0,8,55881,0),
(0,8,55882,0),
(4,28,55896,1),
(0,8,55897,0),
(0,8,55899,0),
(0,8,55901,0),
(0,8,55902,0),
(0,8,55903,0),
(0,8,55904,0),
(0,8,55905,0),
(0,8,55906,0),
(0,8,55907,0),
(0,8,55908,0),
(0,8,55909,0),
(0,8,55910,0),
(0,8,55911,0),
(0,8,55912,0),
(4,39,55916,9),
(4,39,55917,9),
(4,39,55918,9),
(4,39,55919,9),
(4,28,55920,0),
(4,39,55921,9),
(4,39,55922,9),
(4,43,55923,1),
(4,43,55924,1),
(4,43,55925,1),
(4,43,55926,1),
(4,43,55929,1),
(4,43,55930,1),
(4,43,55931,1),
(4,43,55932,1),
(4,28,55935,0),
(4,28,55936,0),
(4,28,55937,0),
(4,28,55938,0),
(4,28,55939,0),
(4,28,55948,0),
(4,28,55949,0),
(4,28,55950,0),
(4,28,55951,0),
(1,28,55963,0),
(4,28,55964,1),
(4,28,55967,1),
(4,43,56042,1),
(4,43,56056,1),
(4,43,56058,1),
(4,43,56059,1),
(4,43,56063,1),
(4,43,56064,1),
(4,43,56076,4),
(4,43,56077,4),
(4,43,56078,4),
(4,43,56079,4),
(4,43,56080,4),
(4,43,56125,1),
(4,24,56134,0),
(4,24,56135,0),
(4,24,56138,0),
(4,24,56139,0),
(4,24,56141,0),
(4,24,56142,0),
(4,28,56143,1),
(4,43,56144,1),
(4,43,56145,1),
(0,8,56146,0),
(4,28,56147,1),
(4,24,56148,0),
(1,24,56149,0),
(4,43,56150,1),
(4,43,56151,1),
(4,43,56154,1),
(4,43,56155,1),
(4,43,56156,1),
(4,28,56157,1),
(1,28,56158,1),
(4,28,56159,1),
(4,48,58043,1),
(4,46,58050,0),
(4,46,58051,0),
(4,46,58052,0),
(4,46,58053,0),
(4,46,58054,0),
(4,46,58055,0),
(4,46,58056,0),
(4,46,58057,0),
(4,46,58058,0),
(4,46,58059,0),
(4,46,58060,0),
(4,46,58061,0),
(4,46,58062,0),
(4,46,58063,0),
(4,46,58064,0),
(4,46,58065,0),
(4,46,58066,0),
(4,46,58067,0),
(4,46,58068,0),
(4,46,58069,0),
(4,46,58070,0),
(4,46,58071,0),
(4,46,58072,0),
(4,46,58074,0),
(4,46,58075,0),
(4,46,58076,0),
(4,46,58077,0),
(4,46,58078,0),
(4,47,58079,0),
(4,47,58080,0),
(4,47,58081,0),
(4,47,58082,0),
(4,47,58083,0),
(4,46,58088,0),
(4,46,58089,0),
(4,46,58090,0),
(4,46,58091,0),
(4,46,58096,0),
(4,46,58097,0),
(4,46,58098,0),
(4,46,58099,0),
(4,46,58101,0),
(4,46,58102,1),
(4,46,58103,1),
(4,46,58104,1),
(4,46,58105,1),
(4,46,58106,1),
(4,46,58107,1),
(4,46,58108,1),
(4,46,58109,1),
(4,46,58112,1),
(4,46,58113,1),
(4,46,58114,1),
(4,46,58115,1),
(4,46,58118,0),
(4,46,58119,0),
(4,46,58120,0),
(4,46,58121,0),
(4,46,58122,0),
(4,46,58123,0),
(4,46,58125,1),
(4,46,58126,1),
(4,46,58127,1),
(4,46,58128,1),
(4,13,61050,0),
(4,13,61051,0),
(4,13,61053,0),
(4,13,61055,0),
(2,13,61067,0),
(4,13,61068,0),
(2,13,61070,0),
(4,13,61071,0),
(8,22,62101,0),
(8,16,62104,0),
(8,16,62105,0),
(8,16,62108,0),
(1,18,62910,1);
END;