Get started with the Flyway integration
此内容尚不支持你的语言。
Flyway manages database schema changes by applying versioned migration scripts. The Community Toolkit hosting integration runs Flyway in a container and mounts your migration directory into it. Use it with a database resource and the Flyway extension for that database provider.
Why use Flyway with Aspire
Section titled “Why use Flyway with Aspire”- Model migrations alongside the database they update.
- Keep migration files in your application repository and mount them read-only into Flyway.
- Let Aspire manage the Flyway container’s lifecycle and show its logs and state in the dashboard.
Prerequisites
Section titled “Prerequisites”- .NET 10 or later and the Aspire CLI.
- Docker to run the Flyway and database containers.
- A database resource and the matching database-specific Flyway extension for connection configuration.
How the integration fits together
Section titled “How the integration fits together”The AppHost declares a Flyway container and provides a host directory containing SQL migration files. Flyway reads those files from /flyway/sql. This package provides the generic Flyway resource; configure the target database through the extension supplied for that database provider.
architecture-beta group apphost(server)[AppHost] service flyway(resource)[Flyway resource] in apphost service database(database)[Database resource] in apphost service scripts(disk)[Migration scripts] scripts:R --> L:flyway flyway:R --> L:database
Start using Flyway
Section titled “Start using Flyway”-
Install the hosting package in the AppHost.
Aspire CLI — 添加 CommunityToolkit.Aspire.Hosting.Flyway 包 aspire add flywayAspire CLI 是交互式的;按提示选择合适的搜索结果:
Aspire CLI — 输出示例 Select an integration to add:> flyway (CommunityToolkit.Aspire.Hosting.Flyway)> Other results listed as selectable options...C# — AppHost.cs #:package CommunityToolkit.Aspire.Hosting.Flyway@*XML — 添加 CommunityToolkit.Aspire.Hosting.Flyway 包引用 <PackageReference Include="CommunityToolkit.Aspire.Hosting.Flyway" Version="*" /> -
Add a
migrationsdirectory to the AppHost project and put Flyway-formatted migration files in it. -
Add a Flyway resource and the database-specific extension to your AppHost. See Configure Flyway in the AppHost for the complete API and a minimal resource example.