DEV Community

Peter Gašparík
Peter Gašparík

Posted on

File based database migration app

I get frustrated if I have to do a task that can be automated or accomplished easier (with less brain activity). I think writing file based database migrations is one of those tasks.

File based database migrations

For those, who don't know, what file based database migrations are. It's basically version control for databases. Every application, that uses database, and evolves over time, will eventually have to change database structure. We can use special files, migrations, to share this change between developers and servers. Migration file is a SQL (or other language) code, that can apply database changes or undo those changes.

Migration framework keeps track of already applied changes and not yet applied changes. You can update to the newest database scheme version or fallback to specific version in time.

Creating migration file

To create a migration file you have to know SQL really well or know specific migration framework commands. In my last job, we did 4-5 migrations in a month. It's not frequent enough to remember all the commands needed to create valid file, but frequent enough to make me angry each time I have to google correct commands.

Migrator

I decided to create a desktop application, that generates this migration file for you. This application should be able to create, update and remove database tables with zero code. I think it's possible to create user interface, that will handle most migration cases.

First of all, I tried to google if this kind of application already exists. I did not have any success finding one. If you know about existing application let me know

The application is called Migrator. It's written in java, so everyone should be able to run it. There might be some bugs and missing features, but I think it's enough to prove the concept. Also, some form labels might be confusing. Unfortunately, I did not add any hints for them, but it might be improved in the future.

craete migration file

Download: https://github.com/pipan/migrator/releases/download/v0.2.2/migrator.jar

Github: https://github.com/pipan/migrator

Current support

Current version of the application supports only phinx migrations (PHP) and MySQL databases.

Possible future support could be for:

  • flyway (java)
  • db-migrate (nodejs)
  • fluent (.net)

I will appreciate any feedback or contributions. The idea is to keep it open source and let community add other database drivers and language support.

You might need Java 12 and higher to run this application

Top comments (0)