rdagumampan / yuniql

Free and open source schema versioning and database migration made natively with .NET/6. NEW THIS MAY 2022! v1.3.15 released!
https://yuniql.io
Apache License 2.0
417 stars 63 forks source link

Working with an existing DB #280

Open rioka opened 2 years ago

rioka commented 2 years ago

I'm not clear what's the best way to start using yuniql with existing databases...

Let's say I have my "v0.00" folder configured, with all the script required to create a database aligned to the current schema, and my staging or production database already in place and full of data; I cannot find a way to easily set "v0.00" as the current database version using yuniql itself.

As far as I can see, there's no clean and direct way to achieve that, the best I can think of is always include some manual hacks I'd rather avoid, also taking into account that it shuold then be replicated on potentially dozens of deployed databases.

What am I missing?

BTW kudos for this tool.

rdagumampan commented 2 years ago

@rioka Thanks for reaching out and apologies for the delay... Summer time in EU :). Its our backlog to write up a documentation for baselining existing database. Hmmm, I think what you can do is to create v0.00 with just simple script like init.sql and a --This is baseline database version statement. Execute this in your staging and production. This will establish the needed tracking tables in the database. Then you can add all the baseline script files in v0.00 and execute first time in dev and test. This enable you to hold all baseline scripts in v0.00 and get skipped in staging and production.

This is still hackish or work around. Sounds like yuniql rebase which is what we need here...