Add Migrator.EnsureDatabaseExistsAsync() for lightweight database creation#217
Merged
Conversation
…ation Adds a virtual method to ensure a database exists without running schema migrations or DDL, addressing the need for Wolverine multi-tenancy to create databases without EF Core's EnsureCreatedAsync() side effects. Each provider implements the appropriate strategy: - SQLite: no-op (auto-creates on connection open) - PostgreSQL: connects to 'postgres' DB, checks/creates via DatabaseSpecification - SQL Server: connects to 'master', checks via DB_ID(), creates with CREATE DATABASE - MySQL: atomic CREATE DATABASE IF NOT EXISTS - Oracle: runs idempotent CreateSchemaStatementFor() PL/SQL block Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
96d1040 to
b5dcfdf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrator.EnsureDatabaseExistsAsync(DbConnection, CancellationToken)as a virtual method on the baseMigratorclass, with provider-specific overrides for all five database providersEnsureCreatedAsync(), which does extra work that interferes with Wolverine (addresses Migrator.EnsureDatabaseExistsAsync() API for easier EF Core testing #211)DatabaseExists()+DatabaseSpecification, SQL Server usesDB_ID()+CREATE DATABASE, MySQL uses atomicCREATE DATABASE IF NOT EXISTS, and Oracle runs the existing idempotentCreateSchemaStatementFor()PL/SQL blockTest plan
ensure_database_exists_is_noop_for_memory,ensure_database_exists_is_noop_for_file)can_ensure_database_that_does_not_exist,ensure_database_is_idempotent) — requires Dockercan_ensure_database_that_does_not_exist,ensure_database_is_idempotent) — requires Dockercan_ensure_database_that_does_not_exist,ensure_database_is_idempotent) — requires Dockerensure_database_is_idempotent) — requires Docker🤖 Generated with Claude Code