migrate

package
v0.316.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 9 Imported by: 0 modules, 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 migrate is muster-migrate: it applies muster's migrations to the database named by DATABASE_URL and exits. Three things run it: the cmd/muster-migrate shim, `muster server db rls-off|rls-on`, and the muster binary invoked as muster-migrate (the image's /muster-migrate symlink, which deployments run as their migrate init container).

🔴 IT IS A CI AND DEVELOPMENT FIXTURE, NOT A DEPLOY STEP. The server migrates itself at boot.

It also carries the ROLLBACK for migration 0007 (row-level security), and the image keeps /muster-migrate for exactly that:

/muster-migrate --rls-off   disable RLS + owner_id DEFAULT 1, so an image
                            built before accounts PR 3a can run against
                            this schema (internal/db/rollback/rls_off.sql)
/muster-migrate --rls-on    re-apply 0007 (undo --rls-off)

(`muster server db rls-off` and `rls-on` are the same two.)

Either flag does ONLY that — no migrations are applied in the same run — and then reads the state back and prints it per owned table, failing if any is wrong. 🔴 Run them from THIS binary (or newer), BEFORE reverting the image: an older /muster-migrate ignores the flag, says "nothing to apply" and exits 0. This exists so the TEMPLATE database that internal/dbtest copies can be migrated ONCE, before the test binaries start — otherwise the first Postgres-backed package to run pays the whole bootstrap under an advisory lock while every other package queues behind it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main(args []string) int

Main is muster-migrate's main(), with argv[1:] passed in. It returns the process's exit code.

func Run

func Run(args []string, getenv func(string) string, stdout, stderr io.Writer) int

Run is Main with its environment and streams given: the server role's `db` subcommand passes the getenv that has resolved DATABASE_URL_FILE.

Types

This section is empty.

Jump to

Keyboard shortcuts

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