From 2eff7a10c24e455554cb1f494b702764a5364774 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Sun, 14 Aug 2022 13:39:31 +0100 Subject: [PATCH] Upgrade go-sqlite3 to v1.14.14 --- go.mod | 2 +- go.sum | 2 ++ sqlutil/db_test.go | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index a03b4d5..6c3c91a 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/gofrs/flock v0.8.0 // indirect github.com/google/go-cmp v0.5.8 github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40 - github.com/mattn/go-sqlite3 v1.14.7 + github.com/mattn/go-sqlite3 v1.14.14 github.com/miscreant/miscreant.go v0.0.0-20200214223636-26d376326b75 github.com/prometheus/client_golang v1.12.2 github.com/russross/blackfriday/v2 v2.1.0 diff --git a/go.sum b/go.sum index 14ab450..2cc4a88 100644 --- a/go.sum +++ b/go.sum @@ -554,6 +554,8 @@ github.com/mattn/go-shellwords v1.0.10/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lL github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.7 h1:fxWBnXkxfM6sRiuH3bqJ4CfzZojMOLVc0UTsTglEghA= github.com/mattn/go-sqlite3 v1.14.7/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/mattn/go-sqlite3 v1.14.14 h1:qZgc/Rwetq+MtyE18WhzjokPD93dNqLGNT3QJuLvBGw= +github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-zglob v0.0.1/go.mod h1:9fxibJccNxU2cnpIKLRRFA7zX7qhkJIQWBb449FYHOo= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= diff --git a/sqlutil/db_test.go b/sqlutil/db_test.go index a91b7e2..e6da51c 100644 --- a/sqlutil/db_test.go +++ b/sqlutil/db_test.go @@ -141,3 +141,41 @@ func TestOpenDB_Write(t *testing.T) { checkTestValue(t, db) } + +func TestOpenDB_Migrations_Legacy(t *testing.T) { + dir, err := ioutil.TempDir("", "") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(dir) + + db, err := sql.Open("sqlite3", dir+"/test.db") + if err != nil { + t.Fatal(err) + } + for _, stmt := range []string{ + "CREATE TABLE schema_migrations (version uint64,dirty bool)", + "INSERT INTO schema_migrations (version, dirty) VALUES (2, 0)", + "CREATE TABLE test (id INTEGER PRIMARY KEY NOT NULL, value TEXT)", + "CREATE INDEX idx_test_value ON test(value)", + } { + if _, err := db.Exec(stmt); err != nil { + t.Fatalf("statement '%s': %v", stmt, err) + } + } + db.Close() + + migrations := []func(*sql.Tx) error{ + Statement("CREATE TABLE test (id INTEGER PRIMARY KEY NOT NULL, value TEXT)"), + Statement("CREATE INDEX idx_test_value ON test(value)"), + Statement("INSERT INTO test (id, value) VALUES (1, 'test')"), + } + + db, err = OpenDB(dir+"/test.db", WithMigrations(migrations)) + if err != nil { + t.Fatal("first open: ", err) + } + defer db.Close() + + checkTestValue(t, db) +} -- GitLab