migrations

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 6 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 migrations holds taskmill's versioned schema migrations.

Each migration is a file named NNNN_name.sql. The placeholder __SCHEMA__ in a file stands for the schema name, which the caller validates. A file whose first line is "-- online" is an online step: see Migration.Online.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Latest

func Latest() int

Latest returns the highest migration version.

func Split added in v0.16.0

func Split(sql string) []string

Split returns the statements of a migration, without its comments. It splits at each semicolon outside quoted text, also inside the body of a DO block or a function: the parts still name what the body does, but only the statements of an online step run one by one.

Types

type Migration

type Migration struct {
	Version int
	Name    string
	SQL     string

	// Online marks an online step: statements that build or drop an index
	// with CONCURRENTLY, which PostgreSQL runs only outside a transaction,
	// one at a time, without blocking writes. Statements holds them, in
	// order.
	Online     bool
	Statements []Statement

	// Blocking names the tables, schema-qualified, on which a migration
	// that is not online builds an index that blocks writes while it reads
	// the table: CREATE INDEX, or a unique or primary key constraint. Tables
	// that the migration creates itself are left out: they are empty.
	Blocking []string
}

Migration is one versioned schema change.

func All

func All(schema string) ([]Migration, error)

All returns every migration for schema, in version order.

func Parse added in v0.15.0

func Parse(file, body, schema string) (Migration, error)

Parse returns the migration that the file named file holds, with the text body, for schema.

type Statement added in v0.15.0

type Statement struct {
	SQL   string
	Index string // the index that it builds or drops, schema-qualified
	Table string // the table that it indexes, schema-qualified; empty for a drop
}

Statement is one statement of an online step.

Jump to

Keyboard shortcuts

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