-
Notifications
You must be signed in to change notification settings - Fork 50
Custom create database scripts seem to break grate #629
Description
Describe the bug
Custom create database scripts seem to break grate.
Grate fails to log in to the database after it has run the database creation script, even though the database IS created, and has the expected user mappings (SQL Server). If you run grate again, it successfully logs in and continues migrating.
I have tried on multiple machines, and with both Trusted_Connection and SQL Server auth (username+password).
This worked in RoundhousE, which is what we are migrating from.
Grate has no issues logging in to newly created DBs when using the default create database functionality (e.g. no custom script), so I'm assuming the root issue is somewhere in the code path for custom create DB scripts.
To Reproduce
See repository for minimal example:
https://github.com/franzvrolijk-if/grate_bug_2025_04
- Run grate with a connection string in a folder containing
createDatabase/createDatabase.sql. The creation script can be the same as grate uses by default which seems to be a simpleCREATE DATABASE $databaseName.
Expected behavior
I would expect grate to create the DB using my script, then continue with migrations on the newly created database.
Logs
Initializing connections.
Running grate v1.8.0 (build date 07/25/2024 09:13:32) against . - grate_bug_2025_04.
Looking in . for scripts to run.
================================================================================
Setup, Backup, Create/Restore/Drop
================================================================================
Running 'createDatabase.sql'.
================================================================================
Grate Structure
================================================================================
An error occurred: Cannot open database "grate_bug_2025_04" requested by the login. The login failed.
Login failed for user '(redacted)'.
Desktop (please complete the following information):
- OS: Windows 10, 64-bit
- grate version: 1.8.0.0 (I did try a couple of previous releases as well)
- Database: Microsoft SQL Server Developer (64-bit), 16.0.1135.2