migrator

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package migrator applies and upgrades the metaxisdata metadata schema.

This is a port of laelia's metadata migrator (backend/manager/migration/migrator.go): embedded, forward-only, semver-ordered SQL migrations with a single cumulative baseline file for fresh installs.

Layout

The migration tree is embedded via go:embed:

migration/
  LATEST.sql                  full cumulative schema at the newest version
  {MAJOR.MINOR}/
    {NNNN}##{desc}.sql        incremental migration, version MAJOR.MINOR.NNNN

The current application version is 0.1, so incrementals live under migration/0.1/ and the baseline version is 0.1.0.

Dual-maintenance model

LATEST.sql is the cumulative schema at the newest version and is applied only to fresh installs. Every future schema change must BOTH (a) append the idempotent DDL to migration/LATEST.sql AND (b) add an incremental file at migration/{MAJOR.MINOR}/{NNNN}##{desc}.sql. The incremental file is what existing deployments execute at startup; LATEST.sql is never re-run on an existing deployment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MigrateSchema

func MigrateSchema(ctx context.Context, db *sql.DB) error

MigrateSchema migrates the metadata database schema to the latest embedded version. It is safe to call on every server startup: fresh installs apply LATEST.sql, and existing deployments apply only pending incrementals. A session-level advisory lock serializes migrations across replicas.

Types

This section is empty.

Jump to

Keyboard shortcuts

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