Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tool to migrate data from badger to mysql or postgresql #1477

Merged
merged 4 commits into from
Jul 18, 2023

Conversation

maraino
Copy link
Contributor

@maraino maraino commented Jul 18, 2023

Description

This PR adds a tool that allows migrating data from BadgerDB to MySQL or PostgreSQL databases.

@github-actions github-actions bot added the needs triage Waiting for discussion / prioritization by team label Jul 18, 2023
@maraino maraino marked this pull request as ready for review July 18, 2023 00:38
@maraino maraino requested a review from hslatman July 18, 2023 00:38
scripts/badger-migration/main.go Outdated Show resolved Hide resolved
scripts/badger-migration/main.go Outdated Show resolved Hide resolved
@joshdrake
Copy link
Contributor

This looks good, just a few nits and two larger questions about runtime/performance:

  • this does not batch inserts/sets in any way, is that possible (just from a brief perusal of the nosql package, doesn't seem so)?
  • do we need to consider "resume" behavior, eg: could we seek the iterator to a given position (for each table) based on user input?

@maraino
Copy link
Contributor Author

maraino commented Jul 18, 2023

@joshdrake

this does not batch inserts/sets in any way, is that possible (just from a brief perusal of the nosql package, doesn't seem so)?

It is not actually possible to do batch inserts with nosql. It is actually possible to create transactions, but it might be problematic for large databases.

do we need to consider "resume" behavior, eg: could we seek the iterator to a given position (for each table) based on user input?

I'll take a look at this

@hslatman hslatman added this to the v0.24.3 milestone Jul 18, 2023
@maraino maraino requested a review from joshdrake July 18, 2023 20:13
joshdrake
joshdrake previously approved these changes Jul 18, 2023
Copy link
Contributor

@joshdrake joshdrake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Member

@hslatman hslatman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nits

scripts/badger-migration/main.go Show resolved Hide resolved
scripts/badger-migration/main.go Outdated Show resolved Hide resolved
@maraino maraino merged commit cbc46d1 into master Jul 18, 2023
12 checks passed
@maraino maraino deleted the badger-migration branch July 18, 2023 21:36
@celevra
Copy link

celevra commented Sep 27, 2023

thank you for your work!
i'm no go specialist and need a little help on how to compile the script:

login blub # go build
main.go:14:2: cannot find package "github.com/dgraph-io/badger/v2" in any of:
        /usr/lib/go-1.18/src/github.com/dgraph-io/badger/v2 (from $GOROOT)
        /root/go/src/github.com/dgraph-io/badger/v2 (from $GOPATH)
/usr/lib/go-1.18/src/github.com/smallstep/nosql/badger/v2/badger.go:12:2: cannot find package "github.com/dgraph-io/badger/v2/options" in any of:
        /usr/lib/go-1.18/src/vendor/github.com/dgraph-io/badger/v2/options (vendor tree)
        /usr/lib/go-1.18/src/github.com/dgraph-io/badger/v2/options (from $GOROOT)
        /root/go/src/github.com/dgraph-io/badger/v2/options (from $GOPATH)
/usr/lib/go-1.18/src/github.com/smallstep/nosql/postgresql/postgresql.go:13:2: cannot find package "github.com/jackc/pgx/v4" in any of:
        /usr/lib/go-1.18/src/vendor/github.com/jackc/pgx/v4 (vendor tree)
        /usr/lib/go-1.18/src/github.com/jackc/pgx/v4 (from $GOROOT)
        /root/go/src/github.com/jackc/pgx/v4 (from $GOPATH)
/usr/lib/go-1.18/src/github.com/smallstep/nosql/postgresql/postgresql.go:14:2: cannot find package "github.com/jackc/pgx/v4/stdlib" in any of:
        /usr/lib/go-1.18/src/vendor/github.com/jackc/pgx/v4/stdlib (vendor tree)
        /usr/lib/go-1.18/src/github.com/jackc/pgx/v4/stdlib (from $GOROOT)
        /root/go/src/github.com/jackc/pgx/v4/stdlib (from $GOPATH)

could you guide me in the right direction?

@celevra
Copy link

celevra commented Mar 25, 2024

any news on how to use it?

@hslatman
Copy link
Member

hslatman commented Apr 2, 2024

@celevra

Start by ensuring you have Go installed according to the instructions: https://go.dev/doc/install. Then follow the steps on https://github.com/smallstep/certificates/blob/master/CONTRIBUTING.md to get started with development. If you still hit issues with the dependencies not being found, try a go mod tidy in the directory of the migration tool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Waiting for discussion / prioritization by team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants