-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running Grate on RoundhousE database - all scripts are new #550
Comments
After checking the codebase more, I think the easiest fix for this, is to make the should be in this kind of format So This should allow to cache multiple tables. |
@erikbra I wonder if this could get your attention? It's blocking our migration from RoundhousE to Grate. |
@Edgaras91 was there a problem using the baseline flag when running grate? There is a configuration option for grate that handles this logic.
I've transitioned about 30 db's from RoundHouse, to Grate with the following process, and have not once run into a single issue:
|
With "baseline" = true in GrateConfiguration.cs it's not running any scripts, logs in console:
when I paste the above path in File Explorer, I do see all the files being physically there (build action: Content) Then when I set baseline back to false, it tries to run 1st script (which it shouldn't). Error:
|
Grate should be picking up files in the directories that it's configured to look at. Would you mind sharing what configuration options you are using, and how you're calling grate? |
They do exist when compiled, before running the application. They do get picked up when baseline = false, so I assume with baseline = true they are simply ignored or whatever, but not run var accountsMigrationConfig = new GrateConfiguration
{
Baseline = false,
CommandTimeout = 1800,
RepositoryPath = configuration.GetValue<string?>("RepositoryPath"),
Version = typeof(Program).Assembly.GetName().Version!.ToString(3),
SchemaName = "RoundhousE",
NonInteractive = true,
CreateDatabase = false,
SqlFilesDirectory = $"{Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)}/db/Accounts}",
ConnectionString = configuration.GetConnectionStringsWithBackwardsCompatibility(ConfigurationExtensions.ConfigDatabase.Accounts)
}; |
Can anyone help me understand if I am doing something wrong? I didn't think it would be this difficult to use this project on existing RoundhousE setup |
@Edgaras91 - I'm not 100% sure that you are seeing the correct wrong behaviour here. I worked a bit on the cache yesterday, and it seems. to be working as expected. The tables GrateScriptsRun, GrateScriptsRunErrors and GrateVersion are tables for versioning the grate structure itself. Every time you run a migration, there will first be two internal migrations run, which run against these tables, to see if there are any changes to the internal grate tables that need to be run (change in the structure of these tables, e.g.) There was an error, #524 , where one of the internal migrations was always run in baseline mode, which doesn't run any of the scripts, but register them as run. This one is fixed now, and will be part of 1.8.0 (to come). However, all of this is only concerning the grate tables themselves, and should not affect the running of the user scripts. I see @jswright91 writes that he has used baseline mode the first time running grate when migrating from RoundhousE. The intent is that this should not be necessary, if specifying RoundhousE as the grate schema to use. But of course, there might be bugs. I don't own a Windows machine, and I have no legacy RoundhousE controlled database available to be able to test this properly. Would any of you be able to provide a minimal sample of a RoundhousE database, especially the values in the RoundhousE tables (hash, etc), as a backup file or something, where you see these problems, so that I can look into them? Because, as i am aware, this should "just work" out of the box, but it's been quite a while since I've tested it. |
I just tried it again with version 1.8.0, running on the existing old roundhousE database, with RoundhousE tables pre-populated, with baseline false, and it just keeps trying to execute my up (one-time) scripts even though they ran before. I did not try to debug grate source code at this time. It is flagging that the scripts have changed. I set the WarnOnOneTimeScriptChanges to true, and it is trying to execute the scripts. I used the same configs as shared earlier. Unfortunately, we can't migrate to grate because of this and I hope someone will try the latest version of grate on an ex roundhouse database and replicate my issue. |
This can be related to this discussion #579. I will take a look later this week. |
For info, @Edgaras91 - the RoundhousE.GrateScriptsRun (if you specify RoundhousE as the grate schema) is used internally by grate. grate still uses ScriptsRun, ScriptsRunErrors and Version tables, in the schema you specified, to handle versioning of your scripts. I have created an issue, #583 , to improve this documentation. But, if you do not try to force Grate to use any special names for ScriptsRun, ScriptsRunErrors, and Version tables, does it still try to run all scripts again, if you have an existing RoundhousE database? The intention is that this should "just work", but there might be some errors in the hash algorithm or other. Unfortunately, I don't have a Windows machine, so I don't have any possibility to create a RoundhousE database to test on. Do you have the option to create a database, or alternatively share an example of one row in your existing RoundhousE.ScriptsRun database (both script text and hash), so that I can make sure that we create the hash exactly the same way as RoundhousE did? |
Ok posted a little too soon, I couldn't find anything that looked promising in the configuration options page, however after digging into the code to try to understand the matching I came across an undocumented flag which seems to solve my problem! Using |
Describe the bug
Using grate.sqlserver, HasRun() check is fetching scripts from RoundhousE.GrateScriptsRun which is wrong when trying to run my scripts (xxxx.NewAddressColumns.sql). My scripts already ran and are in RoundhousE.ScriptsRun table.
To Reproduce
Have an existing RoundhousE tables such as "RoundhousE.ScriptsRun". Specify the "RoundhousE" schema in start-up.
Expected behavior
The existing RoundhousE script to not run again.
Desktop (please complete the following information):
Context
This in
AnsiSqlDatabase
class, this is the cache:private async Task<IDictionary<string, string>> GetScriptsRunCache() => _scriptsRunCache ??= await GetAllScriptsRun();
_scriptsRunCache
is shared across all migration scripts (Grate scripts and user scripts) which is wrong. user scripts should either "refresh" the cache using the correct table "ScriptsRun" or separate instance of theAnsiSqlDatabase
class, or another property to store this (or something else)The text was updated successfully, but these errors were encountered: