From 5163ac782428cddbc7feba4a19fe94f9ae925699 Mon Sep 17 00:00:00 2001 From: Erik Swenson Date: Sun, 5 Nov 2023 14:48:39 -0700 Subject: [PATCH] feature: add rqlite support --- Makefile | 2 +- README.md | 1 + database/rqlite/README.md | 18 + .../migrations/33_create_table.down.sql | 1 + .../migrations/33_create_table.up.sql | 3 + .../migrations/44_alter_table.down.sql | 1 + .../examples/migrations/44_alter_table.up.sql | 1 + database/rqlite/rqlite.go | 334 ++++++++++++++++++ database/rqlite/rqlite_test.go | 322 +++++++++++++++++ go.mod | 1 + go.sum | 2 + internal/cli/build_rqlite.go | 8 + 12 files changed, 693 insertions(+), 1 deletion(-) create mode 100644 database/rqlite/README.md create mode 100644 database/rqlite/examples/migrations/33_create_table.down.sql create mode 100644 database/rqlite/examples/migrations/33_create_table.up.sql create mode 100644 database/rqlite/examples/migrations/44_alter_table.down.sql create mode 100644 database/rqlite/examples/migrations/44_alter_table.up.sql create mode 100644 database/rqlite/rqlite.go create mode 100644 database/rqlite/rqlite_test.go create mode 100644 internal/cli/build_rqlite.go diff --git a/Makefile b/Makefile index 61e035c0e..8e23a43c7 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ SOURCE ?= file go_bindata github github_ee bitbucket aws_s3 google_cloud_storage godoc_vfs gitlab -DATABASE ?= postgres mysql redshift cassandra spanner cockroachdb yugabytedb clickhouse mongodb sqlserver firebird neo4j pgx pgx5 +DATABASE ?= postgres mysql redshift cassandra spanner cockroachdb yugabytedb clickhouse mongodb sqlserver firebird neo4j pgx pgx5 rqlite DATABASE_TEST ?= $(DATABASE) sqlite sqlite3 sqlcipher VERSION ?= $(shell git describe --tags 2>/dev/null | cut -c 2-) TEST_FLAGS ?= diff --git a/README.md b/README.md index c26999424..9243da5a7 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ Database drivers run migrations. [Add a new database?](database/driver.go) * [ClickHouse](database/clickhouse) * [Firebird](database/firebird) * [MS SQL Server](database/sqlserver) +* [RQLite](database/rqlite) ### Database URLs diff --git a/database/rqlite/README.md b/database/rqlite/README.md new file mode 100644 index 000000000..386c72705 --- /dev/null +++ b/database/rqlite/README.md @@ -0,0 +1,18 @@ +# rqlite + +`rqlite://admin:secret@server1.example.com:4001/?level=strong&timeout=5` + +The `rqlite` url scheme is used for both secure and insecure connections. If connecting to an insecure database, pass `x-connect-insecure` in your URL query, or use `WithInstance` to pass an established connection. + +The migrations table name is configurable through the `x-migrations-table` URL query parameter, or by using `WithInstance` and passing `MigrationsTable` through `Config`. + +Other connect parameters are directly passed through to the database driver. For examples of connection strings, see https://github.com/rqlite/gorqlite#examples. + +| URL Query | WithInstance Config | Description | +|------------|---------------------|-------------| +| `x-connect-insecure` | n/a: set on instance | Boolean to indicate whether to use an insecure connection. Defaults to `false`. | +| `x-migrations-table` | `MigrationsTable` | Name of the migrations table. Defaults to `schema_migrations`. | + +## Notes + +* Uses the https://github.com/rqlite/gorqlite driver diff --git a/database/rqlite/examples/migrations/33_create_table.down.sql b/database/rqlite/examples/migrations/33_create_table.down.sql new file mode 100644 index 000000000..72d18c554 --- /dev/null +++ b/database/rqlite/examples/migrations/33_create_table.down.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS pets; \ No newline at end of file diff --git a/database/rqlite/examples/migrations/33_create_table.up.sql b/database/rqlite/examples/migrations/33_create_table.up.sql new file mode 100644 index 000000000..5ad3404d1 --- /dev/null +++ b/database/rqlite/examples/migrations/33_create_table.up.sql @@ -0,0 +1,3 @@ +CREATE TABLE pets ( + name string +); \ No newline at end of file diff --git a/database/rqlite/examples/migrations/44_alter_table.down.sql b/database/rqlite/examples/migrations/44_alter_table.down.sql new file mode 100644 index 000000000..72d18c554 --- /dev/null +++ b/database/rqlite/examples/migrations/44_alter_table.down.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS pets; \ No newline at end of file diff --git a/database/rqlite/examples/migrations/44_alter_table.up.sql b/database/rqlite/examples/migrations/44_alter_table.up.sql new file mode 100644 index 000000000..f0682fcca --- /dev/null +++ b/database/rqlite/examples/migrations/44_alter_table.up.sql @@ -0,0 +1 @@ +ALTER TABLE pets ADD predator bool; diff --git a/database/rqlite/rqlite.go b/database/rqlite/rqlite.go new file mode 100644 index 000000000..14d3bd340 --- /dev/null +++ b/database/rqlite/rqlite.go @@ -0,0 +1,334 @@ +package rqlite + +import ( + "fmt" + "io" + nurl "net/url" + "strconv" + "strings" + + "go.uber.org/atomic" + + "github.com/golang-migrate/migrate/v4" + "github.com/golang-migrate/migrate/v4/database" + "github.com/hashicorp/go-multierror" + "github.com/pkg/errors" + "github.com/rqlite/gorqlite" +) + +func init() { + database.Register("rqlite", &Rqlite{}) +} + +const ( + // DefaultMigrationsTable defines the default rqlite migrations table + DefaultMigrationsTable = "schema_migrations" + + // DefaultConnectInsecure defines the default setting for connect insecure + DefaultConnectInsecure = false +) + +// ErrNilConfig is returned if no configuration was passed to WithInstance +var ErrNilConfig = fmt.Errorf("no config") + +// ErrBadConfig is returned if configuration was invalid +var ErrBadConfig = fmt.Errorf("bad parameter") + +// Config defines the driver configuration +type Config struct { + // ConnectInsecure sets whether the connection uses TLS. Ineffectual when using WithInstance + ConnectInsecure bool + // MigrationsTable configures the migrations table name + MigrationsTable string +} + +type Rqlite struct { + db *gorqlite.Connection + isLocked atomic.Bool + + config *Config +} + +// WithInstance creates a rqlite database driver with an existing gorqlite database connection +// and a Config struct +func WithInstance(instance *gorqlite.Connection, config *Config) (database.Driver, error) { + if config == nil { + return nil, ErrNilConfig + } + + // we use the consistency level check as a database ping + if _, err := instance.ConsistencyLevel(); err != nil { + return nil, err + } + + if len(config.MigrationsTable) == 0 { + config.MigrationsTable = DefaultMigrationsTable + } + + driver := &Rqlite{ + db: instance, + config: config, + } + + if err := driver.ensureVersionTable(); err != nil { + return nil, err + } + + return driver, nil +} + +// OpenURL creates a rqlite database driver from a connect URL +func OpenURL(url string) (database.Driver, error) { + d := &Rqlite{} + return d.Open(url) +} + +func (r *Rqlite) ensureVersionTable() (err error) { + if err = r.Lock(); err != nil { + return err + } + + defer func() { + if e := r.Unlock(); e != nil { + if err == nil { + err = e + } else { + err = multierror.Append(err, e) + } + } + }() + + stmts := []string{ + fmt.Sprintf(`CREATE TABLE IF NOT EXISTS %s (version uint64, dirty bool)`, r.config.MigrationsTable), + fmt.Sprintf(`CREATE UNIQUE INDEX IF NOT EXISTS version_unique ON %s (version)`, r.config.MigrationsTable), + } + + if _, err := r.db.Write(stmts); err != nil { + return err + } + + return nil +} + +// Open returns a new driver instance configured with parameters +// coming from the URL string. Migrate will call this function +// only once per instance. +func (r *Rqlite) Open(url string) (database.Driver, error) { + dburl, config, err := parseUrl(url) + if err != nil { + return nil, err + } + r.config = config + + r.db, err = gorqlite.Open(dburl.String()) + if err != nil { + return nil, err + } + + if err := r.ensureVersionTable(); err != nil { + return nil, err + } + + return r, nil +} + +// Close closes the underlying database instance managed by the driver. +// Migrate will call this function only once per instance. +func (r *Rqlite) Close() error { + r.db.Close() + return nil +} + +// Lock should acquire a database lock so that only one migration process +// can run at a time. Migrate will call this function before Run is called. +// If the implementation can't provide this functionality, return nil. +// Return database.ErrLocked if database is already locked. +func (r *Rqlite) Lock() error { + if !r.isLocked.CAS(false, true) { + return database.ErrLocked + } + return nil +} + +// Unlock should release the lock. Migrate will call this function after +// all migrations have been run. +func (r *Rqlite) Unlock() error { + if !r.isLocked.CAS(true, false) { + return database.ErrNotLocked + } + return nil +} + +// Run applies a migration to the database. migration is guaranteed to be not nil. +func (r *Rqlite) Run(migration io.Reader) error { + migr, err := io.ReadAll(migration) + if err != nil { + return err + } + + query := string(migr[:]) + if _, err := r.db.WriteOne(query); err != nil { + return &database.Error{OrigErr: err, Query: []byte(query)} + } + + return nil +} + +// SetVersion saves version and dirty state. +// Migrate will call this function before and after each call to Run. +// version must be >= -1. -1 means NilVersion. +func (r *Rqlite) SetVersion(version int, dirty bool) error { + deleteQuery := fmt.Sprintf(`DELETE FROM %s`, r.config.MigrationsTable) + statements := []gorqlite.ParameterizedStatement{ + { + Query: deleteQuery, + }, + } + + // Also re-write the schema version for nil dirty versions to prevent + // empty schema version for failed down migration on the first migration + // See: https://github.com/golang-migrate/migrate/issues/330 + insertQuery := fmt.Sprintf(`INSERT INTO %s (version, dirty) VALUES (?, ?)`, r.config.MigrationsTable) + if version >= 0 || (version == database.NilVersion && dirty) { + statements = append(statements, gorqlite.ParameterizedStatement{ + Query: insertQuery, + Arguments: []interface{}{ + version, + dirty, + }, + }) + } + + wr, err := r.db.WriteParameterized(statements) + if err != nil { + for i, res := range wr { + if res.Err != nil { + return &database.Error{OrigErr: err, Query: []byte(statements[i].Query)} + } + } + + // if somehow we're still here, return the original error with combined queries + return &database.Error{OrigErr: err, Query: []byte(deleteQuery + "\n" + insertQuery)} + } + + return nil +} + +// Version returns the currently active version and if the database is dirty. +// When no migration has been applied, it must return version -1. +// Dirty means, a previous migration failed and user interaction is required. +func (r *Rqlite) Version() (version int, dirty bool, err error) { + query := "SELECT version, dirty FROM " + r.config.MigrationsTable + " LIMIT 1" + + qr, err := r.db.QueryOne(query) + if err != nil { + return database.NilVersion, false, nil + } + + if !qr.Next() { + return database.NilVersion, false, nil + } + + if err := qr.Scan(&version, &dirty); err != nil { + return database.NilVersion, false, &database.Error{OrigErr: err, Query: []byte(query)} + } + + return version, dirty, nil +} + +// Drop deletes everything in the database. +// Note that this is a breaking action, a new call to Open() is necessary to +// ensure subsequent calls work as expected. +func (r *Rqlite) Drop() error { + query := `SELECT name FROM sqlite_master WHERE type = 'table'` + + tables, err := r.db.QueryOne(query) + if err != nil { + return &database.Error{OrigErr: err, Query: []byte(query)} + } + + statements := make([]string, 0) + for tables.Next() { + var tableName string + if err := tables.Scan(&tableName); err != nil { + return err + } + + if len(tableName) > 0 { + statement := fmt.Sprintf(`DROP TABLE %s`, tableName) + statements = append(statements, statement) + } + } + + // return if nothing to do + if len(statements) <= 0 { + return nil + } + + wr, err := r.db.Write(statements) + if err != nil { + for i, res := range wr { + if res.Err != nil { + return &database.Error{OrigErr: err, Query: []byte(statements[i])} + } + } + + // if somehow we're still here, return the original error with combined queries + return &database.Error{OrigErr: err, Query: []byte(strings.Join(statements, "\n"))} + } + + return nil +} + +func parseUrl(url string) (*nurl.URL, *Config, error) { + parsedUrl, err := nurl.Parse(url) + if err != nil { + return nil, nil, err + } + + config, err := parseConfigFromQuery(parsedUrl.Query()) + if err != nil { + return nil, nil, err + } + + if parsedUrl.Scheme != "rqlite" { + return nil, nil, errors.Wrap(ErrBadConfig, "bad scheme") + } + + // adapt from rqlite to http/https schemes + if config.ConnectInsecure { + parsedUrl.Scheme = "http" + } else { + parsedUrl.Scheme = "https" + } + + filteredUrl := migrate.FilterCustomQuery(parsedUrl) + + return filteredUrl, config, nil +} + +func parseConfigFromQuery(queryVals nurl.Values) (*Config, error) { + c := Config{ + ConnectInsecure: DefaultConnectInsecure, + MigrationsTable: DefaultMigrationsTable, + } + + migrationsTable := queryVals.Get("x-migrations-table") + if migrationsTable != "" { + if strings.HasPrefix(migrationsTable, "sqlite_") { + return nil, errors.Wrap(ErrBadConfig, "invalid value for x-migrations-table") + } + c.MigrationsTable = migrationsTable + } + + connectInsecureStr := queryVals.Get("x-connect-insecure") + if connectInsecureStr != "" { + connectInsecure, err := strconv.ParseBool(connectInsecureStr) + if err != nil { + return nil, errors.Wrap(ErrBadConfig, "invalid value for x-connect-insecure") + } + c.ConnectInsecure = connectInsecure + } + + return &c, nil +} diff --git a/database/rqlite/rqlite_test.go b/database/rqlite/rqlite_test.go new file mode 100644 index 000000000..9d5c663e5 --- /dev/null +++ b/database/rqlite/rqlite_test.go @@ -0,0 +1,322 @@ +package rqlite + +import ( + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "testing" + + "github.com/dhui/dktest" + "github.com/rqlite/gorqlite" + "github.com/stretchr/testify/assert" + + "github.com/golang-migrate/migrate/v4" + dt "github.com/golang-migrate/migrate/v4/database/testing" + "github.com/golang-migrate/migrate/v4/dktesting" + _ "github.com/golang-migrate/migrate/v4/source/file" +) + +var defaultPort uint16 = 4001 + +var opts = dktest.Options{ + Env: map[string]string{"NODE_ID": "1"}, + PortRequired: true, + ReadyFunc: isReady, +} +var specs = []dktesting.ContainerSpec{ + {ImageName: "rqlite/rqlite:7.21.3", Options: opts}, +} + +func isReady(ctx context.Context, c dktest.ContainerInfo) bool { + ip, port, err := c.Port(defaultPort) + if err != nil { + fmt.Println("error getting port") + return false + } + + statusString := fmt.Sprintf("http://%s:%s/status", ip, port) + fmt.Println(statusString) + + var readyResp struct { + Store struct { + Ready bool `json:"ready"` + } `json:"store"` + } + + resp, err := http.Get(statusString) + if err != nil { + fmt.Println("error getting status") + return false + } + + if resp.StatusCode != 200 { + fmt.Println("statusCode != 200") + return false + } + + body, err := io.ReadAll(resp.Body) + if err != nil { + fmt.Println("error reading body") + return false + } + + if err := json.Unmarshal(body, &readyResp); err != nil { + fmt.Println("error unmarshaling body") + return false + } + + fmt.Printf("reporting ready status %+v\n", readyResp) + return readyResp.Store.Ready +} + +func Test(t *testing.T) { + dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { + ip, port, err := c.Port(defaultPort) + assert.NoError(t, err) + + connectString := fmt.Sprintf("rqlite://%s:%s?level=strong&disableClusterDiscovery=true&x-connect-insecure=true", ip, port) + t.Logf("DB connect string : %s\n", connectString) + + r := &Rqlite{} + d, err := r.Open(connectString) + assert.NoError(t, err) + + dt.Test(t, d, []byte("CREATE TABLE t (Qty int, Name string);")) + }) +} + +func TestMigrate(t *testing.T) { + dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { + ip, port, err := c.Port(defaultPort) + assert.NoError(t, err) + + connectString := fmt.Sprintf("rqlite://%s:%s?level=strong&disableClusterDiscovery=true&x-connect-insecure=true", ip, port) + t.Logf("DB connect string : %s\n", connectString) + + driver, err := OpenURL(connectString) + assert.NoError(t, err) + defer func() { + if err := driver.Close(); err != nil { + return + } + }() + + m, err := migrate.NewWithDatabaseInstance( + "file://./examples/migrations", + "ql", driver) + assert.NoError(t, err) + + dt.TestMigrate(t, m) + }) +} + +func TestBadConnectInsecureParam(t *testing.T) { + dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { + ip, port, err := c.Port(defaultPort) + assert.NoError(t, err) + + connectString := fmt.Sprintf("rqlite://%s:%s?x-connect-insecure=foo", ip, port) + t.Logf("DB connect string : %s\n", connectString) + + _, err = OpenURL(connectString) + assert.ErrorIs(t, err, ErrBadConfig) + }) +} + +func TestBadProtocol(t *testing.T) { + dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { + ip, port, err := c.Port(defaultPort) + assert.NoError(t, err) + + connectString := fmt.Sprintf("postgres://%s:%s/database", ip, port) + t.Logf("DB connect string : %s\n", connectString) + + _, err = OpenURL(connectString) + assert.ErrorIs(t, err, ErrBadConfig) + }) +} + +func TestNoConfig(t *testing.T) { + dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { + ip, port, err := c.Port(defaultPort) + assert.NoError(t, err) + + // gorqlite expects http(s) schemes + connectString := fmt.Sprintf("http://%s:%s?level=strong&disableClusterDiscovery=true", ip, port) + t.Logf("DB connect string : %s\n", connectString) + db, err := gorqlite.Open(connectString) + assert.NoError(t, err) + + _, err = WithInstance(db, nil) + assert.ErrorIs(t, err, ErrNilConfig) + }) +} + +func TestWithInstanceEmptyConfig(t *testing.T) { + dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { + ip, port, err := c.Port(defaultPort) + assert.NoError(t, err) + + // gorqlite expects http(s) schemes + connectString := fmt.Sprintf("http://%s:%s?level=strong&disableClusterDiscovery=true", ip, port) + t.Logf("DB connect string : %s\n", connectString) + db, err := gorqlite.Open(connectString) + assert.NoError(t, err) + + driver, err := WithInstance(db, &Config{}) + assert.NoError(t, err) + + defer func() { + if err := driver.Close(); err != nil { + t.Fatal(err) + } + }() + + m, err := migrate.NewWithDatabaseInstance( + "file://./examples/migrations", + "ql", driver) + assert.NoError(t, err) + + t.Log("UP") + err = m.Up() + assert.NoError(t, err) + + _, err = db.QueryOne(fmt.Sprintf("SELECT * FROM %s", DefaultMigrationsTable)) + assert.NoError(t, err) + + t.Log("DOWN") + err = m.Down() + assert.NoError(t, err) + }) +} + +func TestMigrationTable(t *testing.T) { + dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) { + ip, port, err := c.Port(defaultPort) + assert.NoError(t, err) + + // gorqlite expects http(s) schemes + connectString := fmt.Sprintf("http://%s:%s?level=strong&disableClusterDiscovery=true", ip, port) + t.Logf("DB connect string : %s\n", connectString) + db, err := gorqlite.Open(connectString) + assert.NoError(t, err) + + config := Config{MigrationsTable: "my_migration_table"} + driver, err := WithInstance(db, &config) + assert.NoError(t, err) + + defer func() { + if err := driver.Close(); err != nil { + t.Fatal(err) + } + }() + + m, err := migrate.NewWithDatabaseInstance( + "file://./examples/migrations", + "ql", driver) + assert.NoError(t, err) + + t.Log("UP") + err = m.Up() + assert.NoError(t, err) + + _, err = db.QueryOne(fmt.Sprintf("SELECT * FROM %s", config.MigrationsTable)) + assert.NoError(t, err) + + _, err = db.WriteOne(`INSERT INTO pets (name, predator) VALUES ("franklin", true)`) + assert.NoError(t, err) + + res, err := db.QueryOne(`SELECT name, predator FROM pets LIMIT 1`) + assert.NoError(t, err) + + _ = res.Next() + + // make sure we can use the migrated table + var petName string + var petPredator int + err = res.Scan(&petName, &petPredator) + assert.NoError(t, err) + assert.Equal(t, petName, "franklin") + assert.Equal(t, petPredator, 1) + + t.Log("DOWN") + err = m.Down() + assert.NoError(t, err) + + _, err = db.QueryOne(fmt.Sprintf("SELECT * FROM %s", config.MigrationsTable)) + assert.NoError(t, err) + }) +} + +func TestParseUrl(t *testing.T) { + tests := []struct { + name string + passedUrl string + expectedUrl string + expectedConfig *Config + expectedErr string + }{ + { + "defaults", + "rqlite://localhost:4001", + "https://localhost:4001", + &Config{ConnectInsecure: DefaultConnectInsecure, MigrationsTable: DefaultMigrationsTable}, + "", + }, + { + "configure migration table", + "rqlite://localhost:4001?x-migrations-table=foo", + "https://localhost:4001", + &Config{ConnectInsecure: DefaultConnectInsecure, MigrationsTable: "foo"}, + "", + }, + { + "configure connect insecure", + "rqlite://localhost:4001?x-connect-insecure=true", + "http://localhost:4001", + &Config{ConnectInsecure: true, MigrationsTable: DefaultMigrationsTable}, + "", + }, + { + "invalid migration table", + "rqlite://localhost:4001?x-migrations-table=sqlite_bar", + "", + nil, + "invalid value for x-migrations-table: bad parameter", + }, + { + "invalid connect insecure", + "rqlite://localhost:4001?x-connect-insecure=baz", + "", + nil, + "invalid value for x-connect-insecure: bad parameter", + }, + { + "invalid url", + string([]byte{0x7f}), + "", + nil, + "parse \"\\x7f\": net/url: invalid control character in URL", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + actualUrl, actualConfig, actualErr := parseUrl(tt.passedUrl) + if tt.expectedUrl != "" { + assert.Equal(t, tt.expectedUrl, actualUrl.String()) + } else { + assert.Nil(t, actualUrl) + } + + assert.Equal(t, tt.expectedConfig, actualConfig) + + if tt.expectedErr == "" { + assert.NoError(t, actualErr) + } else { + assert.EqualError(t, actualErr, tt.expectedErr) + } + }) + } +} diff --git a/go.mod b/go.mod index da117acd3..805aa148f 100644 --- a/go.mod +++ b/go.mod @@ -142,6 +142,7 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect + github.com/rqlite/gorqlite v0.0.0-20230708021416-2acd02b70b79 github.com/shopspring/decimal v1.2.0 // indirect github.com/sirupsen/logrus v1.9.2 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect diff --git a/go.sum b/go.sum index 700aff24e..d51fe677c 100644 --- a/go.sum +++ b/go.sum @@ -527,6 +527,8 @@ github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qq github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rqlite/gorqlite v0.0.0-20230708021416-2acd02b70b79 h1:V7x0hCAgL8lNGezuex1RW1sh7VXXCqfw8nXZti66iFg= +github.com/rqlite/gorqlite v0.0.0-20230708021416-2acd02b70b79/go.mod h1:xF/KoXmrRyahPfo5L7Szb5cAAUl53dMWBh9cMruGEZg= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= diff --git a/internal/cli/build_rqlite.go b/internal/cli/build_rqlite.go new file mode 100644 index 000000000..1e3e3a932 --- /dev/null +++ b/internal/cli/build_rqlite.go @@ -0,0 +1,8 @@ +//go:build rqlite +// +build rqlite + +package cli + +import ( + _ "github.com/golang-migrate/migrate/v4/database/rqlite" +)