Clean up for blog presentation

This commit is contained in:
Justin Hawkins 2023-03-05 09:41:13 +10:30
parent 743dafb1b6
commit 1fc1c27267
2 changed files with 15 additions and 4 deletions

6
README.md Normal file
View File

@ -0,0 +1,6 @@
# Embedding PostgreSQL migrations in a Go binary
This is the example project for my [blog entry](https://hawkins.id.au/posts/embedded_sql_migrations_with_tern/).
It shows how to embed SQL migrations and the [tern](https://github.com/JackC/tern) migration tool
into your own Go program.

View File

@ -25,9 +25,11 @@ func NewMigrator(dbDNS string) (Migrator, error) {
if err != nil {
return Migrator{}, err
}
migrator, err := migrate.NewMigratorEx(context.Background(), conn, versionTable, &migrate.MigratorOptions{
DisableTx: false,
})
migrator, err := migrate.NewMigratorEx(
context.Background(), conn, versionTable,
&migrate.MigratorOptions{
DisableTx: false,
})
if err != nil {
return Migrator{}, err
}
@ -63,7 +65,10 @@ func (m Migrator) Info() (int32, int32, string, error) {
if cur {
indicator = "->"
}
info = info + fmt.Sprintf("%2s %3d %s\n", indicator, thisMigration.Sequence, thisMigration.Name)
info = info + fmt.Sprintf(
"%2s %3d %s\n",
indicator,
thisMigration.Sequence, thisMigration.Name)
}
return version, last, info, nil