Upgrade to Go 1.19 (#2347)

This commit is contained in:
Johan Brandhorst-Satzkorn authored and GitHub committed 2022-08-25 12:12:24 -04:00
1 parent 07a4082aa1
commit aef9073fa6
77 files changed
+334 -294

No files matched your search

+21 -21
View File
@@ -3,27 +3,27 @@
//
// Example Usage:
//
// import (
// "testing"
// import (
// "testing"
//
// "github.com/hashicorp/internal/db/assert"
// )
// "github.com/hashicorp/internal/db/assert"
// )
//
// func TestSomeDatabase(t *testing.T) {
// conn, err := sql.Open("postgres", "postgres://postgres:secret@localhost:%s?sslmode=disable")
// if err != nil {
// t.Fatal(err)
// }
// defer conn.Close()
// db, err := gorm.Open("postgres", conn)
// if err != nil {
// t.Fatal(err)
// }
// m := TestModel{}
// if err = rw.Create(&m); err != nil {
// t.Fatal(err)
// }
// dbassert := dbassert.New(t, db)
// dbassert.FieldIsNull(&someModel, "someField")
// }
// func TestSomeDatabase(t *testing.T) {
// conn, err := sql.Open("postgres", "postgres://postgres:secret@localhost:%s?sslmode=disable")
// if err != nil {
// t.Fatal(err)
// }
// defer conn.Close()
// db, err := gorm.Open("postgres", conn)
// if err != nil {
// t.Fatal(err)
// }
// m := TestModel{}
// if err = rw.Create(&m); err != nil {
// t.Fatal(err)
// }
// dbassert := dbassert.New(t, db)
// dbassert.FieldIsNull(&someModel, "someField")
// }
package dbassert
+2
View File
@@ -27,9 +27,11 @@ type ExprValue struct {
// column values for database operations. See: Expr(...)
//
// Set name column to null example:
//
// SetColumnValues(map[string]interface{}{"name": Expr("NULL")})
//
// Set exp_time column to N seconds from now:
//
// SetColumnValues(map[string]interface{}{"exp_time": Expr("wt_add_seconds_to_now(?)", 10)})
func Expr(expr string, args ...interface{}) ExprValue {
return ExprValue{sql: expr, vars: args}
+7 -8
View File
@@ -7,16 +7,15 @@
// prior to creating a schema.Manager. This is generally done in an init
// function of another package, i.e.:
//
// //go:embed postgres
// var postgres embed.FS
// //go:embed postgres
// var postgres embed.FS
//
// func init() {
// schema.RegisterEdition("oss", schema.Postgres, postgres, 0)
// }
// func init() {
// schema.RegisterEdition("oss", schema.Postgres, postgres, 0)
// }
//
// Then a manager can be created and used to apply the migrations:
//
// m := schema.NewManager(ctx, schema.Postgres, db)
// m.ApplyMigrations()
//
// m := schema.NewManager(ctx, schema.Postgres, db)
// m.ApplyMigrations()
package schema
+11 -11
View File
@@ -58,22 +58,22 @@ func (e Editions) Sort() {
// lower number indicates a higher priority. New will panic if the structure
// of the embed.FS is not correct. The files must be structured as follows:
//
// <majorVersion>/
// <minorVersion>_<description>.up.sql
// <majorVersion>/
// <minorVersion>_<description>.up.sql
//
// Where majorVersion and minorVersion are integers. There can be any number of
// leading directories prior to the major versions. For example a directory
// structure like the following is correct:
//
// migrations/oss/postgres/
// 0/
// 01_initial.up.sql
// 1/
// 01_add_columns.up.sql
// 02_rename_table.up.sql
// 2/
// 01_add_new_table.up.sql
// 02_refactor_views.up.sql
// migrations/oss/postgres/
// 0/
// 01_initial.up.sql
// 1/
// 01_add_columns.up.sql
// 02_rename_table.up.sql
// 2/
// 01_add_new_table.up.sql
// 02_refactor_views.up.sql
func New(name string, dialect Dialect, m embed.FS, priority int, opt ...Option) (Edition, error) {
var largestSchemaVersion int
migrations := make(migration.Migrations)
@@ -451,7 +451,7 @@ func (p *Postgres) EnsureMigrationLogTable(ctx context.Context) error {
// GetMigrationLog will retrieve the migration logs from the db for the last
// migration.
// The WithDeleteLog option is supported and will remove all log entries,
// The WithDeleteLog option is supported and will remove all log entries,
// after reading the entries, when provided.
func (p *Postgres) GetMigrationLog(ctx context.Context, opt ...log.Option) ([]*log.Entry, error) {
const op = "postgres.(Postgres).GetMigrationLog"
+1 -1
View File
@@ -19,7 +19,7 @@ type LogEntry struct {
// GetMigrationLog will retrieve the migration logs from the db for the last
// migration. Once it's read the entries, it will delete them from the database.
// The WithDeleteLog option is supported and will remove all log entries when provided.
// The WithDeleteLog option is supported and will remove all log entries when provided.
func (b *Manager) GetMigrationLog(ctx context.Context, opt ...Option) ([]LogEntry, error) {
const op = "schema.GetMigrationLog"
+1
View File
@@ -11,6 +11,7 @@ import (
// postgres contains the sql for creating the base tables used to manage
// migrations.
//
//go:embed base/postgres
var postgres embed.FS
@@ -6,7 +6,6 @@
// belonging to the same project scope.
//
// The repair functionality removes all illegal associations and returns a report.
//
package hook46001
import (
+1
View File
@@ -12,6 +12,7 @@ import (
)
// postgres contains the migrations sql files for postgres oss edition
//
//go:embed postgres
var postgres embed.FS
@@ -38,7 +38,8 @@ type testServer struct {
// 4) asserting some bits about the state of the db.
//
// Tests migration:
// migrations/oss/11/01_server_type_enum.up.sql
//
// migrations/oss/11/01_server_type_enum.up.sql
func Test_ServerEnumChanges(t *testing.T) {
t.Parallel()
require := require.New(t)
@@ -13,7 +13,8 @@ import (
)
// Tests migration:
// migrations/oss/12/01_timestamp_sub_funcs.up.sql
//
// migrations/oss/12/01_timestamp_sub_funcs.up.sql
func TestWtSubSeconds(t *testing.T) {
t.Parallel()
require := require.New(t)
@@ -15,7 +15,8 @@ import (
)
// Tests migration:
// migrations/oss/2/10_auth.up.sql
//
// migrations/oss/2/10_auth.up.sql
func Test_AuthMethodSubtypes(t *testing.T) {
t.Parallel()
assert, require := assert.New(t), require.New(t)