mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2026-08-12 21:21:47 +08:00
e862714d6a
Migration 0013 runs as a single transaction that rebuilds `organizations` and then `ALTER TABLE sso_providers ADD saml_config` / `ADD domain_verified`. On instances where those columns were already created outside Drizzle (declared in schema.ts and added via db:push / an SSO-register round-trip on an intermediate build), the ADD throws "duplicate column name: saml_config". That rolls back the entire 0013 transaction, so 0013 is never recorded in `__drizzle_migrations` and is retried — failing identically — on every boot, crash-looping the server. Add a pre-migrate repair (mirroring the existing repairFailedMigrations() for the 0009 case): when 0013 is unrecorded but the columns already exist, preserve any real SAML provider config, drop the stranded columns so the canonical 0013 runs in full (organizations rebuild included), then restore the preserved values once the columns are re-added. No-op on fresh installs, clean upgrades, and already-migrated databases. This lets affected instances recover automatically on the next boot after upgrading — no manual SQLite surgery required. - src/lib/db/migration-repairs.ts: repairDuplicateSsoColumns + restoreSsoDataAfter0013 - src/lib/db/index.ts: wire both around migrate() - scripts/validate-migrations.ts: cover the broken-upgrade + data-preservation path