migrations

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package migrations reads the migration files of an application and the rows that drel already applied. The CLI prints them, and the boot check of the root package proves that none is pending. See the SDD, S14 and DX-8.

Index

Constants

View Source
const TrackingTable = "drel_migrations"

TrackingTable is the table that drel writes when it applies a migration.

Variables

This section is empty.

Functions

func Applied

func Applied(ctx context.Context, e *drel.Engine) map[string]string

Applied returns the time of each applied migration, keyed by version. A database with no tracking table holds none.

func File

func File(dir string, m Migration, direction string) string

File returns the path of the up file or the down file of a migration.

func Unpack added in v0.2.0

func Unpack(fsys fs.FS, root string) (string, func(), error)

Unpack writes the migrations of an embedded file system into a temporary directory and returns it with the function that removes it.

drel applies migrations from a directory, so an application that carries its migrations in its binary writes them out for the moment of the boot. One artifact therefore holds the server, the front end and the schema.

Types

type Migration

type Migration struct {
	// Version is the fourteen digit version of the file name.
	Version string
	// Name is the part of the file name after the version.
	Name string
}

Migration is one file pair of the migrations directory.

func Pending

func Pending(ctx context.Context, e *drel.Engine, dir string) ([]Migration, error)

Pending returns the migrations that the database does not hold.

func PendingFS added in v0.2.0

func PendingFS(ctx context.Context, e *drel.Engine, sets ...fs.FS) ([]Migration, error)

PendingFS returns the migrations of the embedded sets that the database does not hold.

func Read

func Read(dir string) ([]Migration, error)

Read returns the migrations of the directory, in version order. An absent directory holds none.

func ReadFS added in v0.2.0

func ReadFS(fsys fs.FS) ([]Migration, error)

ReadFS returns the migrations of one embedded set, in version order.

drel writes a migrations_drel.go into the directory of each feature slice, which embeds the SQL files of that slice. See the modules block of drel.yaml.

Jump to

Keyboard shortcuts

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