1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-05 14:23:30 +01:00
bitwarden-server/util/PostgresMigrations/Migrations/20230824202447_ACCESSPOLICY_ADD_DELETE_CASCADE.cs
Thomas Avery 46faecaade
[SM-755] Add EF Secrets Manager cleanup on deletes (#3228)
* Add Delete Cascade for EF AccessPolicy table

* Add AP removal on EF user deletion

* Remove SM entities on EF org delete
2023-09-21 17:22:08 -05:00

64 lines
2.0 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.PostgresMigrations.Migrations;
/// <inheritdoc />
public partial class ACCESSPOLICY_ADD_DELETE_CASCADE : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AccessPolicy_Group_GroupId",
table: "AccessPolicy");
migrationBuilder.DropForeignKey(
name: "FK_AccessPolicy_Project_GrantedProjectId",
table: "AccessPolicy");
migrationBuilder.AddForeignKey(
name: "FK_AccessPolicy_Group_GroupId",
table: "AccessPolicy",
column: "GroupId",
principalTable: "Group",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AccessPolicy_Project_GrantedProjectId",
table: "AccessPolicy",
column: "GrantedProjectId",
principalTable: "Project",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AccessPolicy_Group_GroupId",
table: "AccessPolicy");
migrationBuilder.DropForeignKey(
name: "FK_AccessPolicy_Project_GrantedProjectId",
table: "AccessPolicy");
migrationBuilder.AddForeignKey(
name: "FK_AccessPolicy_Group_GroupId",
table: "AccessPolicy",
column: "GroupId",
principalTable: "Group",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_AccessPolicy_Project_GrantedProjectId",
table: "AccessPolicy",
column: "GrantedProjectId",
principalTable: "Project",
principalColumn: "Id");
}
}