Skip to content

Conversation

@rriski
Copy link

@rriski rriski commented Nov 27, 2025

Based on #1077

This PR adds DuckDB database support, based on the original work in #1077, with the following updates:

  1. Updated DuckDB driver: Replaced github.com/marcboeker/go-duckdb with the official github.com/duckdb/duckdb-go/v2 driver (the project moved to the DuckDB organization starting with v2.5.0)

  2. Standard migrations table name: Changed from gmg_schema_migrations to schema_migrations to match the convention used by other database drivers.

  3. Removed deprecated dependencies:

    • Replaced github.com/hashicorp/go-multierror with stdlib errors.Join() (Go 1.20+)
    • Replaced go.uber.org/atomic with stdlib sync/atomic
    • Replaced deprecated atomic.Bool.CAS() with atomic.Bool.CompareAndSwap()
  4. Align config and tests with the sqlite3 driver

    • Add

DuckDB driver features:

  • File-based database with URL scheme duckdb://path/to/file.db
  • Transaction support for migrations
  • Standard schema migrations table (schema_migrations)

michaelmdresser and others added 5 commits November 27, 2025 14:08
Originally written in https://github.com/kubecost/golang-migrate-duckdb/tree/mmd/make-importable

Signed-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_migrations
to match the convention used by other database drivers.
Copilot AI review requested due to automatic review settings November 27, 2025 13:28
Copy link

Copilot AI left a 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-multierror and uber.org/atomic with stdlib errors.Join() and sync/atomic
  • Standardization: changed migrations table from gmg_schema_migrations to schema_migrations to 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.
Copy link

Copilot AI Nov 27, 2025

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.

Suggested change
// convention of "caller locks" in the Sqlite type.
// convention of "caller locks" in the DuckDB type.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1 @@
DROP TABLE IF EXISTS pets; No newline at end of file
Copy link

Copilot AI Nov 27, 2025

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 be ALTER TABLE pets DROP COLUMN predator;

Suggested change
DROP TABLE IF EXISTS pets;
ALTER TABLE pets DROP COLUMN predator;

Copilot uses AI. Check for mistakes.
@coveralls
Copy link

coveralls commented Nov 27, 2025

Coverage Status

coverage: 54.263% (+0.2%) from 54.049%
when pulling 8debcd4 on rriski:duckdb-support
into 472ef2e on golang-migrate:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants