got saved a RdvQuery

This commit is contained in:
Paul Schneider 2026-09-13 03:09:12 +01:00
commit cbb59f019d
Signed by: notazof
GPG key ID: 1DD5D838E5343B06
17 changed files with 616 additions and 288 deletions

View file

@ -0,0 +1,63 @@
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Yavsc.Models;
#nullable disable
namespace Yavsc.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20260913022000_cleanupLegacyNominativeServiceCommandLocationId")]
public partial class cleanupLegacyNominativeServiceCommandLocationId : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(@"
UPDATE ""NominativeServiceCommand""
SET ""RdvQuery_LocationId"" = COALESCE(""RdvQuery_LocationId"", ""LocationId"")
WHERE ""Discriminator"" = 'RdvQuery'
AND ""LocationId"" IS NOT NULL;
");
migrationBuilder.DropForeignKey(
name: "FK_NominativeServiceCommand_Locations_LocationId",
table: "NominativeServiceCommand");
migrationBuilder.DropIndex(
name: "IX_NominativeServiceCommand_LocationId",
table: "NominativeServiceCommand");
migrationBuilder.DropColumn(
name: "LocationId",
table: "NominativeServiceCommand");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<long>(
name: "LocationId",
table: "NominativeServiceCommand",
type: "bigint",
nullable: true);
migrationBuilder.Sql(@"
UPDATE ""NominativeServiceCommand""
SET ""LocationId"" = ""RdvQuery_LocationId""
WHERE ""Discriminator"" = 'RdvQuery'
AND ""RdvQuery_LocationId"" IS NOT NULL;
");
migrationBuilder.CreateIndex(
name: "IX_NominativeServiceCommand_LocationId",
table: "NominativeServiceCommand",
column: "LocationId");
migrationBuilder.AddForeignKey(
name: "FK_NominativeServiceCommand_Locations_LocationId",
table: "NominativeServiceCommand",
column: "LocationId",
principalTable: "Locations",
principalColumn: "Id");
}
}
}