diff --git a/.github/workflows/db-migration.yml b/.github/workflows/db-migration.yml new file mode 100644 index 0000000..1a1aa07 --- /dev/null +++ b/.github/workflows/db-migration.yml @@ -0,0 +1,36 @@ +name: db-migration + +env: + DOTNET_VERSION: '8.*' # set this to the .NET Core version to use + +on: + workflow_dispatch: + +permissions: + contents: read + +jobs: + bundle: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up .NET Core + uses: actions/setup-dotnet@v2 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: Install dotnet-ef + run: dotnet tool install --global dotnet-ef + + - name: Create migrations bundle + run: dotnet ef migrations bundle -p src/Tgvs --output efbundle.exe + + - name: Upload artifact with migration bundle + uses: actions/upload-artifact@v3 + with: + name: efbundle + path: efbundle.exe + + diff --git a/src/Tgvs/Program.cs b/src/Tgvs/Program.cs index 92a2189..a05090a 100644 --- a/src/Tgvs/Program.cs +++ b/src/Tgvs/Program.cs @@ -1,4 +1,3 @@ -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; using Telegram.Bot; using Telegram.Bot.Polling; @@ -49,10 +48,4 @@ app.MapControllers(); -using (var scope = app.Services.CreateScope()) -{ - var db = scope.ServiceProvider.GetRequiredService(); - db.Database.Migrate(); -} - app.Run();