MySql.AddDatabase creates database for resource#8912
Merged
RussKie merged 3 commits intomicrosoft:mainfrom Apr 29, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for creating MySQL databases via the AddDatabase API, including the ability to specify custom creation scripts. Key changes include:
- New functional tests demonstrating database creation with and without a custom script.
- Updates to MySqlServerResource and MySqlDatabaseResource for improved database resource management and connection string construction.
- Enhancements to MySqlBuilderExtensions for handling resource events and creating databases upon resource readiness.
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Hosting.MySql.Tests/MySqlFunctionalTests.cs | Added tests for AddDatabase functionality with regular and custom scripts |
| src/Aspire.Hosting.MySql/MySqlServerResource.cs | Updated to track database resources with new properties |
| src/Aspire.Hosting.MySql/MySqlDatabaseResource.cs | Revised connection string property using MySqlConnectionStringBuilder |
| src/Aspire.Hosting.MySql/MySqlCreateDatabaseScriptAnnotation.cs | Introduced annotation class for custom database creation scripts |
| src/Aspire.Hosting.MySql/MySqlBuilderExtensions.cs | Added event subscriptions and database creation logic based on resource readiness |
| playground/mysql/MySqlDb.AppHost/Program.cs | Adjusted setup to include multiple databases, including one with a custom script |
| playground/mysql/MySql.ApiService/Program.cs | Added keyed MySQL data source and an endpoint to query data from the custom script database |
Files not reviewed (1)
- playground/mysql/MySql.ApiService/MySql.ApiService.http: Language not supported
Contributor
Author
0556888 to
6d752bb
Compare
Contributor
|
Note that very soon we may want to change how these scripts to use the init scripts support provided by each container instead of invoking these with ADO.NET. But it should not matter for this PR right now. |
sebastienros
approved these changes
Apr 29, 2025
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Resolves #8294
Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?doc-ideatemplatebreaking-changetemplatediagnostictemplate