Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
rriski wants to merge6 commits intogolang-migrate:master
base:master
Choose a base branch
Loading
fromrriski:duckdb-support

Conversation

@rriski
Copy link

Based on#1077

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

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

  2. Standard migrations table name: Changed fromgmg_schema_migrations toschema_migrations to match the convention used by other database drivers.

  3. Removed deprecated dependencies:

    • Replacedgithub.com/hashicorp/go-multierror with stdliberrors.Join() (Go 1.20+)
    • Replacedgo.uber.org/atomic with stdlibsync/atomic
    • Replaced deprecatedatomic.Bool.CAS() withatomic.Bool.CompareAndSwap()
  4. Align config and tests with the sqlite3 driver

    • Add

DuckDB driver features:

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

CopilotAI review requested due to automatic review settingsNovember 27, 2025 13:28
Copy link
Contributor

CopilotAI 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 deprecatedhashicorp/go-multierror anduber.org/atomic with stdliberrors.Join() andsync/atomic
  • Standardization: changed migrations table fromgmg_schema_migrations toschema_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
FileDescription
internal/cli/build_duckdb.goBuild tag file to conditionally include DuckDB driver
go.modAdded DuckDB v2.5.3 dependency and updated related transitive dependencies
database/duckdb/duckdb.goCore DuckDB driver implementation with migration support
database/duckdb/duckdb_test.goTest suite covering migration operations and configuration
database/duckdb/examples/migrations/*.sqlExample migration files for testing
database/duckdb/README.mdDocumentation for DuckDB driver usage
README.mdAdded DuckDB to list of supported databases
MakefileAdded 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.

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 theSqlite type.
// convention of "caller locks" in theDuckDB type.

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

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;

Suggested change
DROPTABLEIF EXISTS pets;
ALTERTABLEpets DROP COLUMN predator;

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

coveralls commentedNov 27, 2025
edited
Loading

Coverage Status

coverage: 54.64% (+0.2%) from 54.432%
when pulling07972ca on rriski:duckdb-support
into89e308c on golang-migrate:master.

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.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

Copilot code reviewCopilotCopilot left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@rriski@coveralls@michaelmdresser

[8]ページ先頭

©2009-2025 Movatter.jp