Documentation
¶
Index ¶
- func BackfillPublicIDs[T any](ctx context.Context, db *gorm.DB) error
- func CleanupOrphanedResources[T any, R any](ctx context.Context, db *gorm.DB, fkColumn string) error
- func CreateIndexIfNotExists[T any](ctx context.Context, db *gorm.DB, indexName string, columns ...string) error
- func DropIndex[T any](ctx context.Context, db *gorm.DB, indexName string) error
- func FoldCostAggregatesIntoBuckets[T any](ctx context.Context, db *gorm.DB) error
- func GetColumnName(db *gorm.DB, column string) string
- func MigrateFieldFromGobToJSON[T any, S any](ctx context.Context, db *gorm.DB, fieldName string) error
- func MigrateJsonToTable[T any](ctx context.Context, db *gorm.DB, columnName string, ...) error
- func MigrateNetIPFieldFromBlobToJSON[T any](ctx context.Context, db *gorm.DB, fieldName string, indexName string) error
- func MigrateNewField[T any](ctx context.Context, db *gorm.DB, columnName string, defaultValue any) error
- func MigrateSetupKeyToHashedSetupKey[T any](ctx context.Context, db *gorm.DB) error
- func RemoveDuplicatePeerKeys(ctx context.Context, db *gorm.DB) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BackfillPublicIDs ¶ added in v0.75.0
func CleanupOrphanedResources ¶ added in v0.68.2
func CleanupOrphanedResources[T any, R any](ctx context.Context, db *gorm.DB, fkColumn string) error
CleanupOrphanedResources deletes rows from the table of model T where the foreign key column (fkColumn) references a row in the table of model R that no longer exists.
func CreateIndexIfNotExists ¶ added in v0.50.0
func FoldCostAggregatesIntoBuckets ¶ added in v0.75.1
FoldCostAggregatesIntoBuckets migrates a per-request cost table from the old "stored aggregate" shape (cost_usd + cache_cost_usd columns) to the per-bucket breakdown, where the total and cache portion are derived on read instead.
The fold preserves both aggregates exactly for historical rows: the cache total moves into cached_input_cost_usd and the remainder into input_cost_usd, so a row's derived total and cache cost still match what it reported before the upgrade. The finer split is genuinely unknown for those rows — the old schema never recorded a read/write or input/output division — so it is lumped rather than guessed; only rows written after the upgrade carry a true four-way split.
Dropping the columns before folding would zero every historical row's cost, so the update runs first and the drop only happens once it succeeds. A table with no cost_usd column has already been migrated (or was created fresh) and is skipped.
func MigrateFieldFromGobToJSON ¶
func MigrateFieldFromGobToJSON[T any, S any](ctx context.Context, db *gorm.DB, fieldName string) error
MigrateFieldFromGobToJSON migrates a column from Gob encoding to JSON encoding. T is the type of the model that contains the field to be migrated. S is the type of the field to be migrated.
func MigrateJsonToTable ¶ added in v0.53.0
func MigrateNetIPFieldFromBlobToJSON ¶ added in v0.27.5
func MigrateNetIPFieldFromBlobToJSON[T any](ctx context.Context, db *gorm.DB, fieldName string, indexName string) error
MigrateNetIPFieldFromBlobToJSON migrates a Net IP column from Blob encoding to JSON encoding. T is the type of the model that contains the field to be migrated.
func MigrateNewField ¶ added in v0.36.0
func MigrateSetupKeyToHashedSetupKey ¶ added in v0.31.0
Types ¶
This section is empty.