- Notifications
You must be signed in to change notification settings - Fork1.5k
Add DuckDB support with official driver and modern stdlib#1337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Pull request overview
This PR adds DuckDB database support to the golang-migrate library using the official DuckDB Go driver (v2.5.3+) and modernizes dependencies by replacing deprecated libraries with Go stdlib equivalents.
Key Changes:
- Integration of official DuckDB driver (
github.com/duckdb/duckdb-go/v2) with full migration support - Modernization: replaced deprecated
hashicorp/go-multierroranduber.org/atomicwith stdliberrors.Join()andsync/atomic - Standardization: changed migrations table from
gmg_schema_migrationstoschema_migrationsto align with other drivers
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
internal/cli/build_duckdb.go | Build tag file to conditionally include DuckDB driver |
go.mod | Added DuckDB v2.5.3 dependency and updated related transitive dependencies |
database/duckdb/duckdb.go | Core DuckDB driver implementation with migration support |
database/duckdb/duckdb_test.go | Test suite covering migration operations and configuration |
database/duckdb/examples/migrations/*.sql | Example migration files for testing |
database/duckdb/README.md | Documentation for DuckDB driver usage |
README.md | Added DuckDB to list of supported databases |
Makefile | Added duckdb to DATABASE_TEST targets |
💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.
| // ensureVersionTable checks if versions table exists and, if not, creates it. | ||
| // Note that this function locks the database, which deviates from the usual | ||
| // convention of "caller locks" in the Sqlite type. |
CopilotAINov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Comment references 'Sqlite type' but this is the DuckDB driver. Update to 'DuckDB type' for accuracy.
| // convention of "caller locks" in theSqlite type. | |
| // convention of "caller locks" in theDuckDB type. |
| @@ -0,0 +1 @@ | |||
| DROP TABLE IF EXISTS pets; No newline at end of file | |||
CopilotAINov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The down migration drops the entire table instead of removing only the column added in the up migration. This is inconsistent with the up migration which only adds a column. Should beALTER TABLE pets DROP COLUMN predator;
| DROPTABLEIF EXISTS pets; | |
| ALTERTABLEpets DROP COLUMN predator; |
coveralls commentedNov 27, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Originally written inhttps://github.com/kubecost/golang-migrate-duckdb/tree/mmd/make-importableSigned-off-by: Michael Dresser <michaelmdresser@gmail.com>
- Replace github.com/marcboeker/go-duckdb with github.com/duckdb/duckdb-go/v2- Replace hashicorp/go-multierror with stdlib errors.Join (Go 1.20+)- Replace deprecated atomic.Bool.CAS with CompareAndSwap- Replace go.uber.org/atomic with sync/atomic
Rename migration table from gmg_schema_migrations to schema_migrationsto match the convention used by other database drivers.
Based on#1077
This PR adds DuckDB database support, based on the original work in#1077, with the following updates:
Updated DuckDB driver: Replaced
github.com/marcboeker/go-duckdbwith the officialgithub.com/duckdb/duckdb-go/v2driver (the project moved to the DuckDB organization starting with v2.5.0)Standard migrations table name: Changed from
gmg_schema_migrationstoschema_migrationsto match the convention used by other database drivers.Removed deprecated dependencies:
github.com/hashicorp/go-multierrorwith stdliberrors.Join()(Go 1.20+)go.uber.org/atomicwith stdlibsync/atomicatomic.Bool.CAS()withatomic.Bool.CompareAndSwap()Align config and tests with the sqlite3 driver
DuckDB driver features:
duckdb://path/to/file.dbschema_migrations)