Documentation
¶
Overview ¶
Package migration provides helpers for detecting and preprocessing SQL migration files produced by common migration tools (goose, dbmate, golang-migrate). The output is always plain up-only DDL that the schema parser can consume without modification.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Preprocess ¶
Preprocess returns the up-only DDL for the file. For FormatPlain or FormatGolangMigrate (up files), the contents are returned unchanged. For FormatAuto, Detect is run first. The returned slice is always a fresh allocation so callers may modify it freely.
Types ¶
type Format ¶
type Format string
Format identifies the migration file format.
const ( // FormatPlain means the file contains raw DDL with no migration markers. // Preprocess returns the contents unchanged. FormatPlain Format = "plain" // FormatGoose means the file uses goose-style markers // (-- +goose Up / -- +goose Down / -- +goose StatementBegin/End). FormatGoose Format = "goose" // FormatDBMate means the file uses dbmate-style markers // (-- migrate:up / -- migrate:down). FormatDBMate Format = "dbmate" // FormatGolangMigrate means the file is part of a golang-migrate pair: // *.up.sql holds the up DDL; *.down.sql should be skipped entirely. FormatGolangMigrate Format = "golang-migrate" // FormatAuto instructs Detect to infer the format from file path and // contents. It is the default when no format is configured. FormatAuto Format = "auto" )
Click to show internal directories.
Click to hide internal directories.