riverqueue/river

River Schema Migration Improvement

safaci2000 opened this issue · 2 comments

I realize that everyone has their favorite coolaid but applying the migrations with the current pattern makes it a bit difficult to implement. I was wondering if there was a way to run the river CLI tool to generate a SQL patch of the given changes?

Most people have already chosen a tool they like and are actively using it, so having yet another way to modify the SQL schema is a bit distasteful. Now we have two different tools that have write access to a DB that need to be both installed, managed and executed as part of a given deployment.

Given the wide range of options in the ecosystem. (See below), I was wondering if we could just create a SQL

What I'd like to see is something like.

river migrate-up --dry ## or pick your favorite syntax to achieve the goal.

SQL:

-- migrate-up
ALTER TABLE add COLUMN.... 

--migrate-down
ALTER TABLE DROP COLUMN....

How you choose to integrate the SQL into your migration tool is up to you, but at least give me the SQL that will be executed.

I think having this option is a good idea, and we'll add it to the CLI in some form.

I'm working on a larger change right now though, and don't expect to get to it right away. For the time being, if you want to do this, just grab the SQL files from source:

https://github.com/riverqueue/river/tree/master/rivermigrate/migration

They should fit easily into most migration frameworks. You can omit migration 001 because that just brings in a migration table that you won't be using.

Thank you! The SQL itself is very helpful as well. Thank you!