Help us shape the future of Go! Take the 2026 Go Developer Survey

migrationcompat

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 13 Imported by: 0

README

Generated-file contract fixtures

Each directory here holds the migration files one tanGO release's own tango makemigrations wrote, unedited. The Generated-file contract promises they keep working on every later v0.x release, and two tests hold it to that on SQLite and PostgreSQL:

  • compat_test.go in this directory compiles every version's files, applies them one at a time to a fresh database, and rolls back and reapplies each reversible one.
  • generated_files_test.go in internal/cli checks that each file's // tango:migration-json header decodes to exactly the steps its Go literal compiles to. It also checks that tango makemigrations, given the release app's recorded -tango-dump-models output (models.json), finds nothing left to generate.
Directory Written by
v0_0_1 tango v0.0.1
v0_0_2 tango v0.0.2
v0_1_0 tango v0.1.0
v0_2_0 tango v0.2.0
unreleased this checkout's generator, for the step kinds no release has emitted yet

Regenerating

generate.sh builds a small app against one tanGO version, evolves its models through a fixed series of stages, and runs that version's own CLI after each stage. The stages cover:

  • creating tables with unique, indexed, foreign-key and timestamp columns;
  • adding columns;
  • changing unique and index flags;
  • dropping an index, a column and a table;
  • renaming a field and a model, and a widening type change (only on releases that support them);
  • a bounded string (tango:"varchar=n") added, narrowed from text, widened and made text again (only on v0.4.0 and later, and unreleased).

Then it replaces the version's directory here.

./generate.sh v0.0.2               # a released version, fetched through the Go module proxy
./generate.sh v0.1.0 local         # this checkout, saved as v0.1.0: run before tagging v0.1.0
./generate.sh unreleased local     # after changing what the generator writes

Adding a release's output is a release checklist step, and the Release workflow refuses a tag whose directory is missing or not listed in Generators. When you add a new directory, add it to Generators in versions.go, which both tests read. Never edit a released version's files by hand: they stand for what that release's users have in their repositories.

Documentation

Overview

Package migrationcompat holds, under one directory per tanGO version, the migration files that version's own `tango makemigrations` wrote, and lists them for the Generated-file contract tests. See README.md.

Index

Constants

This section is empty.

Variables

View Source
var Generators = []Generator{
	{Dir: "v0_0_1", Migrations: v001.Migrations},
	{Dir: "v0_0_2", Migrations: v002.Migrations},
	{Dir: "v0_1_0", Migrations: v010.Migrations},
	{Dir: "v0_2_0", Migrations: v020.Migrations},
	{Dir: "v0_3_0", Migrations: v030.Migrations},
	{Dir: "v0_3_1", Migrations: v031.Migrations},
	{Dir: "v0_4_0", Migrations: v040.Migrations},
	{Dir: "v0_5_0", Migrations: v050.Migrations},
	{Dir: "v0_6_0", Migrations: v060.Migrations},
	{Dir: "v0_7_0", Migrations: v070.Migrations},
	{Dir: "v0_8_0", Migrations: v080.Migrations},
	{Dir: "unreleased", Migrations: migrations.Migrations},
}

Generators is every fixture directory. Add a release's here when generate.sh adds it.

Functions

This section is empty.

Types

type Generator

type Generator struct {
	Dir        string                // the fixture directory, beside this file
	Migrations []migration.Migration // what its migration files compile to
}

Generator is one generator's fixtures.

Directories

Path Synopsis
unreleased
v0_0_1
v0_0_2
v0_1_0
v0_2_0
v0_3_0
v0_3_1
v0_4_0
v0_5_0
v0_6_0
v0_7_0
v0_8_0

Jump to

Keyboard shortcuts

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