grate: Database already exists exception - Database Name is always Case Sensitive even when it shouldn't be
When running a deployment I’m getting the following exception raised:
Unhandled exception: Microsoft.Data.SqlClient.SqlException (0x80131904): Database 'RetractedDatabaseName' already exists. Choose a different database name.
This is the command line:
-cs "Data Source="RetractedServerName.test.local, 1433";Initial Catalog=RetractedDatabaseName;Trust Server Certificate=True;Authentication=ActiveDirectoryIntegrated" -ct 6000 --verbosity Debug -f Grate
I’m not expecting it to try and create the database!
MacOS BigSur 11.6.1
I suspect this may be due to grate/Configuration/GrateConfiguration Line 52
public bool CreateDatabase { get; init; } = true;
And I’m not finding a corresponding command line option to turn that off.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (10 by maintainers)
Commits related to this issue
- fix #167: Ensure that a sql server database name that differs only by case doesn't error without good reason — committed to wokket/grate by wokket 2 years ago
- #167: Perform exists check simply by trying to connect to the dtabase. If we get a specific error than it (probably) doesn't exist. — committed to wokket/grate by wokket 2 years ago
- #167: Happy now. Same logic as normal exists (normal connection, query just has a where clause) to look for the specific name. Base method also returns false on error — committed to wokket/grate by wokket 2 years ago
@erikbra I’m having a hard time finding any negatives to your proposal.
That is correct.
e.g. If my Database Name is
HiFiSounds
thenwill return back the exact same underlying
database_id
value. PassingHiFiSounds
to grate will work fine, but passinghifiSOUNDS
will cause the aforementioned exception.