Documentation
¶
Overview ¶
Package migrations contains one-shot, idempotent schema migrations invoked from the server's startup AutoMigrate flow.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BackfillRefIDs ¶
BackfillRefIDs copies id → ref_id for every row whose ref_id is empty. Idempotent: safe to run on every server start.
func CreateRefIDIndexes ¶
CreateRefIDIndexes creates the unique indexes that enforce ref_id uniqueness. Run after BackfillRefIDs so existing rows can satisfy the constraint. Uses CREATE UNIQUE INDEX IF NOT EXISTS for idempotency.
Each index is silently skipped (rather than failing) when its required column is absent. The missing column should have been added by AutoMigrate earlier in startup; if it wasn't, the problem will surface when the column is first used rather than here with a cryptic SQL error. The pre-flight check matches the equivalent guard in BackfillRefIDs and keeps both helpers safe on partially-migrated DBs.
Types ¶
This section is empty.