Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,24 @@ SELECT 1
FROM ""Notifications"".""EmailTemplates"" AS template
WHERE template.""Id"" = scheduled.""EmailTemplateId"");");

migrationBuilder.CreateIndex(
name: "IX_ScheduledNotifications_EmailTemplateId",
schema: "Notifications",
table: "ScheduledNotifications",
column: "EmailTemplateId");
migrationBuilder.Sql(
@"CREATE INDEX IF NOT EXISTS ""IX_ScheduledNotifications_EmailTemplateId""
ON ""Notifications"".""ScheduledNotifications"" (""EmailTemplateId"");");

migrationBuilder.AddForeignKey(
name: "FK_ScheduledNotifications_EmailTemplates_EmailTemplateId",
schema: "Notifications",
table: "ScheduledNotifications",
column: "EmailTemplateId",
principalSchema: "Notifications",
principalTable: "EmailTemplates",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.Sql(
@"DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM pg_constraint
WHERE conname = 'FK_ScheduledNotifications_EmailTemplates_EmailTemplateId'
AND conrelid = '""Notifications"".""ScheduledNotifications""'::regclass) THEN
ALTER TABLE ""Notifications"".""ScheduledNotifications""
ADD CONSTRAINT ""FK_ScheduledNotifications_EmailTemplates_EmailTemplateId""
FOREIGN KEY (""EmailTemplateId"")
REFERENCES ""Notifications"".""EmailTemplates"" (""Id"")
ON DELETE RESTRICT;
END IF;
END $$;");
}

/// <inheritdoc />
Expand Down
Loading