Skip to content

Conversation

@RussKie
Copy link
Contributor

@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 Copilot and sebastienros 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 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
Contributor 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.

@RussKie RussKie enabled auto-merge (squash) April 29, 2025 01:04
@RussKie RussKie merged commit 8306d90 into dotnet:main Apr 29, 2025
173 of 174 checks passed
@RussKie RussKie deleted the 8294 branch April 29, 2025 01:17
@github-actions github-actions bot locked and limited conversation to collaborators May 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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