Get started with the Flyway integration

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

⭐ Community Toolkit

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.

  • 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.
  • .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.

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
  1. Install the hosting package in the AppHost.

    Aspire CLI — CommunityToolkit.Aspire.Hosting.Flyway Paket hinzufügen
    aspire add flyway

    Die Aspire CLI ist interaktiv; das passende Suchergebnis wählen, wenn gefragt:

    Aspire CLI — Beispielausgabe
    Select an integration to add:
    > flyway (CommunityToolkit.Aspire.Hosting.Flyway)
    > Other results listed as selectable options...
  2. Add a migrations directory to the AppHost project and put Flyway-formatted migration files in it.

  3. 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.