Can you run Grate programmatically like you could with RoundHousE? #579
-
We have an upgrader utility that references roundhouse.dll that I would like to migrate to Grate. We run scripts on multiple databases with RoundhousE like this:
Is there any way to do the same with Grate? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Yes, you could. From the NuGet package, it adds up a README for brief guidance on how to do that. With grate version starting from 1.6, please check the doc here |
Beta Was this translation helpful? Give feedback.
-
Got this working to a point but had some issues setting the ScriptsRun, ScriptsRunError and Version table names as I used to be able to in RoundhousE. The GrateConfiguration() has these properties but setting them does not seem to have any effect unless I apply them in a specific way.
this seems to ignore many of the settings, does not execute scripts in SqlFilesDirectory and does not create any ScriptsRun tables. If I use serviceCollection.AddGrate(builder => builder); as shown in the doc I do get the GrateScriptsRun tables and another set for the scripts run from SqlFileDirectory but they are just SchemaName.ScriptsRun. I finally managed to get this to work as follows:
Notice the .WithConfiguration(config) which seemed to be the only way I could get the ScriptsRun table naming to work. I tried this with serviceCollection.AddGrate(config) with and without the latter .WithConfiguration(config) but this did not work and I didn't actually get any scripts run or any ScriptsRun tables created at all. Reasoning Hope this helps anyone who is trying to do the same and facing the issues I was. |
Beta Was this translation helpful? Give feedback.
-
I have another issue with this in that when I run the process again for a different product and hence with a different name for the ScriptsRun tables it fails on script 02_create_scripts_run_table.sql with the error: Script has changed since the last time it was run. By default this is not allowed - scripts that run once should never change. To change this behavior to a warning, please set WarnOnOneTimeScriptChanges to true and run again. Stopping execution. but despite setting WarnOnOneTimeScriptChanges() and WarnAndIgnoreOnOneTimeScriptChanges() I still get this error and cannot create other Product tables. With RoundhousE I had WarnOnOneTimeScriptChanges = true and Silent = true to make this work. The only workaround I can see for this is to delete the GrateScriptsRun tables every time I run the process on each database so this is ignored and the new tables are added or updated. If I don't it fails when I switch to another product and therefore table names, even if they already exist. It would be better if this were allowed and one of the above options did indeed ignore the issue and allow things to proceed. I will try tomorrow using different schema names but I suspect I would have the same issue. |
Beta Was this translation helpful? Give feedback.
Yes, you could. From the NuGet package, it adds up a README for brief guidance on how to do that. With grate version starting from 1.6, please check the doc here
Duplicated with #384