erikbra / grate

grate - the SQL scripts migration runner
MIT License
209 stars 40 forks source link

Adding historical SQL scripts #580

Closed philcart closed 1 month ago

philcart commented 2 months ago

Our application is a .Net 7.0 Blazor app with a MS SQL database. The database is also used by a separate legacy app that will need to be maintained for another couple of years.

Currently all table creation/changes are done via EF migrations that run on application startup. Any view, function or procedure changes are handled via Grate migrations.

With Grate working so well, we'd like to standardise on having Grate perform all the database changes.

What's the best way of adding SQL scripts for all the historical EF migrations but not have them run?

jswright91 commented 2 months ago

Add all of your legacy scripts, and then you can run grate with the --baseline parameter.

Baseline - This instructs grate to mark the scripts as run, but not to actually run anything against the database. Use this option if you already have scripts that have been run through other means (and BEFORE you start the new ones).

see the docs: https://erikbra.github.io/grate/configuration-options/

philcart commented 2 months ago

@jswright91 know it's been a couple of days but wanted to thank you for the reply. Haven't tried it out yet due to shifting priorities, but that definitely looks like it'll do what we need. Cheers

philcart commented 1 month ago

This worked just as expected