Skip to content

MySql.AddDatabase creates database for resource #8912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

RussKie
Copy link
Member

@RussKie RussKie commented Apr 22, 2025

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

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

@RussKie RussKie requested review from sebastienros and Copilot April 22, 2025 07:13
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Apr 22, 2025
@RussKie RussKie requested a review from mitchdenny April 22, 2025 07:13
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@RussKie
Copy link
Member Author

RussKie commented Apr 22, 2025

I pretty much copied the changeset from #8022, #8086 and #8085.

@RussKie RussKie added area-integrations Issues pertaining to Aspire Integrations packages and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Apr 22, 2025
@RussKie RussKie force-pushed the 8294 branch 2 times, most recently from 0556888 to 6d752bb Compare April 22, 2025 08:07
@RussKie RussKie added the mysql Issues related to MySQL integrations label Apr 22, 2025
@RussKie RussKie self-assigned this Apr 24, 2025
@sebastienros
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-integrations Issues pertaining to Aspire Integrations packages mysql Issues related to MySQL integrations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AddDatabase should create database for MySql resource
2 participants