migrations

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 3 Imported by: 0

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

func BackfillRefIDs(db *gorm.DB) error

BackfillRefIDs copies id → ref_id for every row whose ref_id is empty. Idempotent: safe to run on every server start.

func CreateRefIDIndexes

func CreateRefIDIndexes(db *gorm.DB) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL