Skip to content

Commit

Permalink
Revert "feat: add duckdb support (#696)" (#717)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfridman authored Mar 13, 2024
1 parent 9024628 commit f13ed73
Show file tree
Hide file tree
Showing 26 changed files with 6 additions and 228 deletions.
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ test-packages:
test-packages-short:
go test -test.short $(GO_TEST_FLAGS) $$(go list ./... | grep -v -e /tests -e /bin -e /cmd -e /examples)

test-e2e: test-e2e-postgres test-e2e-mysql test-e2e-clickhouse test-e2e-vertica test-e2e-ydb test-e2e-turso test-e2e-duckdb
test-e2e: test-e2e-postgres test-e2e-mysql test-e2e-clickhouse test-e2e-vertica test-e2e-ydb test-e2e-turso

test-e2e-postgres:
go test $(GO_TEST_FLAGS) ./tests/e2e -dialect=postgres
Expand All @@ -62,9 +62,6 @@ test-e2e-ydb:
test-e2e-turso:
go test $(GO_TEST_FLAGS) -parallel=1 ./tests/e2e -dialect=turso

test-e2e-duckdb:
go test $(GO_TEST_FLAGS) -parallel=1 ./tests/e2e -dialect=duckdb

docker-cleanup:
docker stop -t=0 $$(docker ps --filter="label=goose_test" -aq)

Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ This will install the `goose` binary to your `$GOPATH/bin` directory.
For a lite version of the binary without DB connection dependent commands, use the exclusive build tags:

```shell
go build -tags='no_postgres no_mysql no_sqlite3 no_ydb no_duckdb' -o goose ./cmd/goose
go build -tags='no_postgres no_mysql no_sqlite3 no_ydb' -o goose ./cmd/goose
```

For macOS users `goose` is available as a [Homebrew Formulae](https://formulae.brew.sh/formula/goose#default):
Expand Down Expand Up @@ -81,7 +81,6 @@ Drivers:
clickhouse
vertica
ydb
duckdb
Examples:
goose sqlite3 ./foo.db status
Expand All @@ -98,7 +97,6 @@ Examples:
goose clickhouse "tcp://127.0.0.1:9000" status
goose vertica "vertica://user:password@localhost:5433/dbname?connection_load_balance=1" status
goose ydb "grpcs://localhost:2135/local?go_query_mode=scripting&go_fake_tx=scripting&go_query_bind=declare,numeric" status
goose duckdb ./foo.db status
GOOSE_DRIVER=sqlite3 GOOSE_DBSTRING=./foo.db goose status
GOOSE_DRIVER=sqlite3 GOOSE_DBSTRING=./foo.db goose create init sql
Expand Down
8 changes: 0 additions & 8 deletions cmd/goose/driver_duckdb.go

This file was deleted.

5 changes: 1 addition & 4 deletions cmd/goose/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ Drivers:
vertica
ydb
turso
duckdb
Examples:
goose sqlite3 ./foo.db status
Expand All @@ -270,16 +269,14 @@ Examples:
goose clickhouse "tcp://127.0.0.1:9000" status
goose vertica "vertica://user:password@localhost:5433/dbname?connection_load_balance=1" status
goose ydb "grpcs://localhost:2135/local?go_query_mode=scripting&go_fake_tx=scripting&go_query_bind=declare,numeric" status
goose turso "libsql://dbname.turso.io?authToken=token" status
goose duckdb ./foo.db status
goose turso "libsql://dbname.turso.io?authToken=token" status
GOOSE_DRIVER=sqlite3 GOOSE_DBSTRING=./foo.db goose status
GOOSE_DRIVER=sqlite3 GOOSE_DBSTRING=./foo.db goose create init sql
GOOSE_DRIVER=postgres GOOSE_DBSTRING="user=postgres dbname=postgres sslmode=disable" goose status
GOOSE_DRIVER=mysql GOOSE_DBSTRING="user:password@/dbname" goose status
GOOSE_DRIVER=redshift GOOSE_DBSTRING="postgres://user:[email protected]:5439/db" goose status
GOOSE_DRIVER=turso GOOSE_DBSTRING="libsql://dbname.turso.io?authToken=token" goose status
GOOSE_DRIVER=duckdb GOOSE_DBSTRING=./foo.db goose status
Options:
`
Expand Down
2 changes: 0 additions & 2 deletions database/dialect.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const (
DialectVertica Dialect = "vertica"
DialectYdB Dialect = "ydb"
DialectTurso Dialect = "turso"
DialectDuckDB Dialect = "duckdb"
)

// NewStore returns a new [Store] implementation for the given dialect.
Expand All @@ -45,7 +44,6 @@ func NewStore(dialect Dialect, tablename string) (Store, error) {
DialectVertica: &dialectquery.Vertica{},
DialectYdB: &dialectquery.Ydb{},
DialectTurso: &dialectquery.Turso{},
DialectDuckDB: &dialectquery.Duckdb{},
}
querier, ok := lookup[dialect]
if !ok {
Expand Down
2 changes: 1 addition & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func OpenDBWithDriver(driver string, dbstring string) (*sql.DB, error) {
}

switch driver {
case "postgres", "pgx", "sqlite3", "sqlite", "mysql", "sqlserver", "clickhouse", "vertica", "azuresql", "ydb", "libsql", "duckdb":
case "postgres", "pgx", "sqlite3", "sqlite", "mysql", "sqlserver", "clickhouse", "vertica", "azuresql", "ydb", "libsql":
return sql.Open(driver, dbstring)
default:
return nil, fmt.Errorf("unsupported driver %s", driver)
Expand Down
3 changes: 0 additions & 3 deletions dialect.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const (
DialectTiDB Dialect = database.DialectTiDB
DialectVertica Dialect = database.DialectVertica
DialectYdB Dialect = database.DialectYdB
DialectDuckDB Dialect = database.DialectDuckDB
)

func init() {
Expand Down Expand Up @@ -53,8 +52,6 @@ func SetDialect(s string) error {
d = dialect.Ydb
case "turso":
d = dialect.Turso
case "duckdb":
d = dialect.Duckdb
default:
return fmt.Errorf("%q: unknown dialect", s)
}
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/ClickHouse/clickhouse-go/v2 v2.17.1
github.com/go-sql-driver/mysql v1.7.1
github.com/jackc/pgx/v5 v5.5.2
github.com/marcboeker/go-duckdb v1.5.6
github.com/mfridman/interpolate v0.0.2
github.com/microsoft/go-mssqldb v1.6.0
github.com/ory/dockertest/v3 v3.10.0
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgx
github.com/lib/pq v0.0.0-20180327071824-d34b9ff171c2 h1:hRGSmZu7j271trc9sneMrpOW7GN5ngLm8YUZIPzf394=
github.com/libsql/sqlite-antlr4-parser v0.0.0-20230802215326-5cb5bb604475 h1:6PfEMwfInASh9hkN83aR0j4W/eKaAZt/AURtXAXlas0=
github.com/libsql/sqlite-antlr4-parser v0.0.0-20230802215326-5cb5bb604475/go.mod h1:20nXSmcf0nAscrzqsXeC2/tA3KkV2eCiJqYuyAgl+ss=
github.com/marcboeker/go-duckdb v1.5.6 h1:5+hLUXRuKlqARcnW4jSsyhCwBRlu4FGjM0UTf2Yq5fw=
github.com/marcboeker/go-duckdb v1.5.6/go.mod h1:wm91jO2GNKa6iO9NTcjXIRsW+/ykPoJbQcHSXhdAl28=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
Expand Down
2 changes: 1 addition & 1 deletion goose_cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func buildGooseCLI(t *testing.T, lite bool) gooseBinary {
"-ldflags=-s -w -X main.version=" + gooseTestBinaryVersion,
}
if lite {
args = append(args, "-tags=no_clickhouse no_mssql no_mysql no_vertica no_postgres no_duckdb")
args = append(args, "-tags=no_clickhouse no_mssql no_mysql no_vertica no_postgres")
}
args = append(args, "./cmd/goose")
build := exec.Command("go", args...)
Expand Down
39 changes: 0 additions & 39 deletions internal/dialect/dialectquery/duckdb.go

This file was deleted.

1 change: 0 additions & 1 deletion internal/dialect/dialects.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ const (
Vertica Dialect = "vertica"
Ydb Dialect = "ydb"
Turso Dialect = "turso"
Duckdb Dialect = "duckdb"
)
2 changes: 0 additions & 2 deletions internal/dialect/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ func NewStore(d Dialect) (Store, error) {
querier = &dialectquery.Ydb{}
case Turso:
querier = &dialectquery.Turso{}
case Duckdb:
querier = &dialectquery.Duckdb{}
default:
return nil, fmt.Errorf("unknown querier dialect: %v", d)
}
Expand Down
25 changes: 0 additions & 25 deletions internal/testdb/duckdb.go

This file was deleted.

6 changes: 0 additions & 6 deletions internal/testdb/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package testdb
type options struct {
bindPort int
debug bool
// for embedded databases
databaseFile string
}

type OptionsFunc func(o *options)
Expand All @@ -16,7 +14,3 @@ func WithBindPort(n int) OptionsFunc {
func WithDebug(b bool) OptionsFunc {
return func(o *options) { o.debug = b }
}

func WithDatabaseFile(p string) OptionsFunc {
return func(o *options) { o.databaseFile = p }
}
5 changes: 0 additions & 5 deletions internal/testdb/testdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,3 @@ func NewVertica(options ...OptionsFunc) (db *sql.DB, cleanup func(), err error)
func NewYdb(options ...OptionsFunc) (db *sql.DB, cleanup func(), err error) {
return newYdb(options...)
}

// NewDuckDB opens a DuckDB database file. Returns a db connection and a cleanup function.
func NewDuckDB(options ...OptionsFunc) (db *sql.DB, cleanup func(), err error) {
return newDuckDB(options...)
}
6 changes: 1 addition & 5 deletions tests/e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const (
dialectMySQL = "mysql"
dialectYdb = "ydb"
dialectTurso = "turso"
dialectDuckDB = "duckdb"
)

// Flags.
Expand Down Expand Up @@ -69,7 +68,7 @@ func TestMain(m *testing.M) {
flag.Parse()

switch *dialect {
case dialectPostgres, dialectMySQL, dialectYdb, dialectTurso, dialectDuckDB:
case dialectPostgres, dialectMySQL, dialectYdb, dialectTurso:
default:
log.Printf("dialect not supported: %q", *dialect)
os.Exit(1)
Expand Down Expand Up @@ -118,9 +117,6 @@ func newDockerDB(t *testing.T) (*sql.DB, error) {
db, cleanup, err = testdb.NewYdb(options...)
case dialectTurso:
db, cleanup, err = testdb.NewTurso(options...)
case dialectDuckDB:
options = append(options, testdb.WithDatabaseFile(filepath.Join(t.TempDir(), "duck.db")))
db, cleanup, err = testdb.NewDuckDB(options...)
default:
return nil, fmt.Errorf("unsupported dialect: %q", *dialect)
}
Expand Down
4 changes: 0 additions & 4 deletions tests/e2e/migrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,6 @@ func getTableNames(db *sql.DB) (tableNames []string, _ error) {
return tableNames, nil
case dialectTurso:
return getTableNamesThroughQuery(db, `SELECT NAME FROM sqlite_master where type='table' and name!='sqlite_sequence' ORDER BY NAME;`)
case dialectDuckDB:
return getTableNamesThroughQuery(db,
`SELECT table_name FROM information_schema.tables ORDER BY table_name`,
)
default:
return nil, fmt.Errorf("getTableNames not supported with dialect %q", *dialect)
}
Expand Down
23 changes: 0 additions & 23 deletions tests/e2e/testdata/duckdb/migrations/00001_a.sql

This file was deleted.

10 changes: 0 additions & 10 deletions tests/e2e/testdata/duckdb/migrations/00002_b.sql

This file was deleted.

13 changes: 0 additions & 13 deletions tests/e2e/testdata/duckdb/migrations/00003_c.sql

This file was deleted.

15 changes: 0 additions & 15 deletions tests/e2e/testdata/duckdb/migrations/00004_d.sql

This file was deleted.

11 changes: 0 additions & 11 deletions tests/e2e/testdata/duckdb/migrations/00005_e.sql

This file was deleted.

15 changes: 0 additions & 15 deletions tests/e2e/testdata/duckdb/migrations/00006_f.sql

This file was deleted.

Loading

0 comments on commit f13ed73

Please sign in to comment.