Closed franzvrolijk-tietoevry closed 4 months ago
I have the same issue. I have a RoundhousE database, running Grate did create the Grate tables (GrateScriptsRun etc), but even with them, grate.sqlserver is still trying to execute the runAfterCreateDatabase scripts. Logs:
nfo: Grate.Migration[0] Skipping 'AlterDatabase', alterDatabase does not exist.
info: Grate.Migration[0]
info: Grate.Migration[0] Looking for Run After Create Database scripts in "D:\Projects\database\Hercules.Database.Console\bin\Debug\net8.0/db/Accounts\runAfterCreateDatabase".
info: Grate.Migration[0] --------------------------------------------------------------------------------
info: grate.Migration.DbMigrator[0] Running '0000.BaselineSchema.sql'.
fail: grate.Migration.DbMigrator[0] 0000.BaselineSchema.sql: Could not drop object '[redacted]' because it is referenced by a FOREIGN KEY constraint.
Fased the same issue. Seems like spaces in default folder configuration brakes folder name comparison
src\grate.core\Configuration\FoldersConfiguration.cs. Line 40 src\grate.core\Migration\GrateMigrator.cs. Line 159.
Yes, this just looks like a plain old bug. The name of the folder does not equal the name of this constant. The folder configuration is a bit messy, and due for a rewrite. But, I think I see the problem, and can provide a work-around for this now, with out re-writing the whole folder configuration right now.
Describe the bug Documentation states:
However, when running grate against a backup of an existing database (not created by grate, does not contain any grate tables):
After
I would not be expecting
The database was not created from scratch by grate, so why is it running the scripts in this folder?
To Reproduce
Expected behavior
I would expect grate to skip these scripts as the database already existed prior to the run.
Desktop
Additional context
Am I misunderstanding the documentation? Do the grate tables need to exist beforehand for grate to not run runAfterCreateDatabase-scripts?
In my case there are no other scripts (or folders) present than the ones in runAfterCreateDatabase.