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

Mixing sql and go migrations #1081

Unanswered
yogimogi asked this question in Q&A
Discussion options

I am new to database migrations with Golang. I am trying out golang-migrate with pgx/v5. After having installed migrate I ran following commands from the terminal on a MAC.

mkdir migrations
migrate create -ext sql -dir ./migrations/ -seq create_user_table
/tmp/migrations/000001_create_user_table.up.sql
/tmp/migrations/000001_create_user_table.down.sql
migrate create -ext go -dir ./migrations/ -seq add_seed_data
/tmp/migrations/000001_add_seed_data.up.go
/tmp/migrations/000001_add_seed_data.down.go
migrate -path ./migrations/ -database "pgx5://postgres:some_password@localhost:5432/example?sslmode=disable" -verbose up

Error I get is
2024年05月05日 17:21:27 error: duplicate migration file: 000001_create_user_table.down.sql

Both sets of .go and .sql files get created with 000001_ prefix.
Is it even legal to mix go and sql migrations? If yes, what's the best way to handle this?

regards, Yogi

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /