snapshot of https://github.com/golang-migrate/migrate.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
CI / test (1.26.x) (push) Failing after 5s
CI / Check coverage (push) Has been skipped
CI / lint (push) Failing after 41s
CI / test (1.25.x) (push) Failing after 54s
CI / Release a new version (push) Has been skipped

This commit is contained in:
upstream-mirror
2026-09-15 21:52:57 +05:00
commit 9f3bffc2d3
405 changed files with 27657 additions and 0 deletions

56
migration_test.go Normal file
View File

@@ -0,0 +1,56 @@
package migrate
import (
"fmt"
"io"
"log"
"strings"
)
func ExampleNewMigration() {
// Create a dummy migration body, this is coming from the source usually.
body := io.NopCloser(strings.NewReader("dumy migration that creates users table"))
// Create a new Migration that represents version 1486686016.
// Once this migration has been applied to the database, the new
// migration version will be 1486689359.
migr, err := NewMigration(body, "create_users_table", 1486686016, 1486689359)
if err != nil {
log.Fatal(err)
}
fmt.Print(migr.LogString())
// Output:
// 1486686016/u create_users_table
}
func ExampleNewMigration_nilMigration() {
// Create a new Migration that represents a NilMigration.
// Once this migration has been applied to the database, the new
// migration version will be 1486689359.
migr, err := NewMigration(nil, "", 1486686016, 1486689359)
if err != nil {
log.Fatal(err)
}
fmt.Print(migr.LogString())
// Output:
// 1486686016/u <empty>
}
func ExampleNewMigration_nilVersion() {
// Create a dummy migration body, this is coming from the source usually.
body := io.NopCloser(strings.NewReader("dumy migration that deletes users table"))
// Create a new Migration that represents version 1486686016.
// This is the last available down migration, so the migration version
// will be -1, meaning NilVersion once this migration ran.
migr, err := NewMigration(body, "drop_users_table", 1486686016, -1)
if err != nil {
log.Fatal(err)
}
fmt.Print(migr.LogString())
// Output:
// 1486686016/d drop_users_table
}