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.