migrations

package
v1.1.16 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package migrations creates and upgrades the CMS's database schema from SQL files embedded in the module, so host applications need no external migration tool.

Each supported engine has its own directory of migration files under sql/, sharing one version sequence: sql/postgres/0007_x.sql and sql/mysql/0007_x.sql are the same change expressed twice. The DDL dialects differ too much to translate mechanically — identity columns, timestamp types, and the fact that MySQL cannot index a TEXT column all need a human decision — so they are maintained side by side.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, db *sqldb.DB, logger *slog.Logger) error

Run applies any migrations that have not yet been applied, in version order. It is safe to call on every startup.

On Postgres each file runs in its own transaction, so a failure rolls back. MySQL and MariaDB commit DDL implicitly, so a failure there can leave a partially applied migration needing manual repair; the version is only recorded on success, so a re-run retries the whole file.

Types

This section is empty.

Jump to

Keyboard shortcuts

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