Skip to content

Migrate your files between different Go migration tools

License

Notifications You must be signed in to change notification settings

musinit/migradaptor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

migradaptor

Tool for adapting migration files for different library formats. Current version allows to adapt to golang-migrate from several sources:

Test

About

Once I faced with an issue to change our corporate migrations library in Golang from rubenv/sql-migrate to golang-migrate and it was so hard. There are several caveats that you should know about, so it can save you some time:

  • You have to split each sql-migrate file in 2 files: up and down migration.
  • By default, migrations in sql-migrate are running in transaction-default mode, but in golang-migrate you have to wrap it in BEGIN;COMMIT; for transactions.
  • Golang-migrate doesn't like the same timestamp for different files.
  • You can't create several indexes concurrently without adding x-multi-statement=true flag for DB connection. However, please note that this flag will break your CREATE FUNCTION ... AS $$ symbol.

That's why I decided to start this lib. I hope there will be more sources (like rubenv/sql-migrate), so people can save time if they need to change their migration lib and adapt their migration files from one format to another. Feel free to suggest an Issue or PR.

Getting started

Install

go install github.com/musinit/migradaptor/...@latest

Use

migradaptor -src={source_folder} -dst={destination_folder}

Supported migrations source formats

Questions or Feedback?

You can use GitHub Issues for feedback or questions.

TODO

  • processing multiple concurrent indexes in single file, splitting the file by the number of such CREATE INDEX CONCURRENTLY commands.

About

Migrate your files between different Go migration tools

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages