Closed JaDuyve closed 6 months ago
Aha! Good catch! I thought I had tests covering this, but apparently not (strange...). I'll try to write some, and fix the issue.
I think PR #514 should solve this, do you agree? I make sure to set the _tokens to null whenever I clone the DbMigrator
@erikbra This fixes the issue I'm having. Thanks a lot!
Lovely, @JaDuyve! It is included in release 1.7.2. Thanks for a detailed bug report and solid analysis 😄
Describe the bug The grate internal structure scripts fail when using CreateDatabase scripts. From what I can see, it's caused because the DbMigrator instance is reused from the CreateDatabase scripts. This instance already has the private instance of
_tokens
initialized. Because it's already initialized, the custom UserTokens for the grate internal scripts will not be added to_tokens
causing TokenReplacer not replacing all supposed tokens and intern, the script will fail.These tokens aren't taken into account. https://github.com/erikbra/grate/blob/a5d3212f8d19e6af031207916a63c0435339cfeb/src/grate.core/Migration/GrateMigrator.cs#L576-L587
Because
_tokens
is already initialized.https://github.com/erikbra/grate/blob/a5d3212f8d19e6af031207916a63c0435339cfeb/src/grate.core/Migration/DbMigrator.cs#L249-L254
I think this is issue will occur when anything has run before grate structure.
Could the solution be to create for the grate internal scripts a new instance of GrateMigrator?
To Reproduce Run grate for new database with CreateDatabase scripts.
Expected behavior Grate internal structure scripts run without errors.
Screenshots
Desktop (please complete the following information):