grate icon indicating copy to clipboard operation
grate copied to clipboard

runAfterCreateDatabase are run even if database isn't created from scratch by grate

Open franzvrolijk-tietoevry opened this issue 8 months ago • 2 comments

Describe the bug Documentation states:

3. runAfterCreateDatabase (Anytime scripts).
This directory is only processed if the database was created from scratch by grate. 
Maybe you need to add user accounts or similar?

However, when running grate against a backup of an existing database (not created by grate, does not contain any grate tables):

Initializing connections.
Running grate v1.6.0 (build date 02/12/2024 21:11:54) against . - DbsBasicData.
Looking in *******\src\Database\DbsBasicData for scripts to run.
================================================================================
Setup, Backup, Create/Restore/Drop
================================================================================
Trying to check the database DbsBasicData database on .
Database DbsBasicData querying with result 1
================================================================================
Grate Structure
================================================================================
================================================================================
Versioning
================================================================================
 Migrating DbsBasicData from version 0.0.0.0 to 1.0.
 Versioning DbsBasicData database with version 1.0.
================================================================================
Migration Scripts
================================================================================
Skipping 'BeforeMigration', beforeMigration does not exist.
Skipping 'AlterDatabase', alterDatabase does not exist.

Looking for Run After Create Database scripts in "*******\src\Database\DbsBasicData\runAfterCreateDatabase".
--------------------------------------------------------------------------------
  Running '0001_Alter_Database_DbsBasicData.sql'.

After

Trying to check the database DbsBasicData database on . Database DbsBasicData querying with result 1

I would not be expecting

Looking for Run After Create Database scripts in...

The database was not created from scratch by grate, so why is it running the scripts in this folder?

To Reproduce

  1. Have an existing database with no grate tables
  2. Run grate (with scripts in runAfterCreateDatabase)

Expected behavior

I would expect grate to skip these scripts as the database already existed prior to the run.

Desktop

  • OS: Windows 11

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.

franzvrolijk-tietoevry avatar Jun 04 '24 16:06 franzvrolijk-tietoevry