fix(db): register legacy task migrations
CI - Build & Test / Backend (.NET) (push) Successful in 50s
CI - Build & Test / Backend integration (PostgreSQL/Toxiproxy) (push) Failing after 58s
CI - Build & Test / Frontend (Vue/TS) (push) Has been cancelled
CI - Build & Test / Security Check (push) Has been cancelled
CI - Build & Test / Deploy Nexus (push) Has been cancelled
CI - Build & Test / Backend (.NET) (push) Successful in 50s
CI - Build & Test / Backend integration (PostgreSQL/Toxiproxy) (push) Failing after 58s
CI - Build & Test / Frontend (Vue/TS) (push) Has been cancelled
CI - Build & Test / Security Check (push) Has been cancelled
CI - Build & Test / Deploy Nexus (push) Has been cancelled
This commit is contained in:
@@ -1,49 +1,59 @@
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Nexus.Api.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Nexus.Api.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[DbContext(typeof(NexusDbContext))]
|
||||
[Migration("20260618233000_AddTaskParentChild")]
|
||||
public partial class AddTaskParentChild : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "ParentTaskId",
|
||||
table: "Tasks",
|
||||
type: "uuid",
|
||||
nullable: true);
|
||||
// This historical migration originally lacked EF discovery
|
||||
// metadata. Keep the catch-up operations idempotent so existing
|
||||
// installations and fresh PostgreSQL databases converge safely.
|
||||
migrationBuilder.Sql(
|
||||
"""
|
||||
ALTER TABLE "Tasks"
|
||||
ADD COLUMN IF NOT EXISTS "ParentTaskId" uuid;
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Tasks_ParentTaskId",
|
||||
table: "Tasks",
|
||||
column: "ParentTaskId");
|
||||
CREATE INDEX IF NOT EXISTS "IX_Tasks_ParentTaskId"
|
||||
ON "Tasks" ("ParentTaskId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Tasks_Tasks_ParentTaskId",
|
||||
table: "Tasks",
|
||||
column: "ParentTaskId",
|
||||
principalTable: "Tasks",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.SetNull);
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM pg_constraint
|
||||
WHERE conname = 'FK_Tasks_Tasks_ParentTaskId'
|
||||
AND conrelid = '"Tasks"'::regclass
|
||||
) THEN
|
||||
ALTER TABLE "Tasks"
|
||||
ADD CONSTRAINT "FK_Tasks_Tasks_ParentTaskId"
|
||||
FOREIGN KEY ("ParentTaskId")
|
||||
REFERENCES "Tasks" ("Id")
|
||||
ON DELETE SET NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
""");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Tasks_Tasks_ParentTaskId",
|
||||
table: "Tasks");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Tasks_ParentTaskId",
|
||||
table: "Tasks");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ParentTaskId",
|
||||
table: "Tasks");
|
||||
migrationBuilder.Sql(
|
||||
"""
|
||||
ALTER TABLE "Tasks"
|
||||
DROP CONSTRAINT IF EXISTS "FK_Tasks_Tasks_ParentTaskId";
|
||||
DROP INDEX IF EXISTS "IX_Tasks_ParentTaskId";
|
||||
ALTER TABLE "Tasks"
|
||||
DROP COLUMN IF EXISTS "ParentTaskId";
|
||||
""");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user