migrations

package
v11.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package migrations supplies the authorization policy tables' DDL, rendered for a dialect and table prefix.

The platform deliberately does not ship a numbered migration file. Migration files are numbered globally per consumer, so a platform-owned number would collide with the consumer's own the moment either side added one. The version is therefore always the consumer's to choose.

If you already run database/migrate, hand SQL to WithGeneratedMigration and the tables are created by your normal migration run — no DDL copied into your repository, nothing to keep in sync as this package evolves:

ddl, err := migrations.SQL(dialect.Postgres, database.DefaultTablePrefix)
// ...
m, err := migrate.New(dialect.Postgres, myMigrations,
	migrate.WithGeneratedMigration(44, "create_authorization_tables", ddl),
)

Statements is the same DDL split into individually executable statements, for callers running it some other way — a different migration tool, or a test that just wants the tables.

The rendering and prefix vetting live in database/ddl, shared with every other schema-shipping package in this module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SQL

func SQL(d dialect.Dialect, prefix string) (string, error)

SQL renders the same DDL as Statements, joined back into one migration body. It is what you hand to database/migrate's WithGeneratedMigration, so the tables are created by the consumer's own migration run instead of being copied into their repository.

func Statements

func Statements(d dialect.Dialect, prefix string) ([]string, error)

Statements renders the DDL for the dialect against the given table prefix and splits it into individually executable statements, each table before its indexes.

func ValidatePrefix

func ValidatePrefix(prefix string) error

ValidatePrefix reports whether prefix yields a legal SQL identifier for every table and index this package creates.

Types

This section is empty.

Jump to

Keyboard shortcuts

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