1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 07:36:14 -05:00

Organization integrations and configuration database schemas (#5553)

* Organization integrations and configuration database schemas

* Format EF files
This commit is contained in:
Matt Bishop
2025-03-26 11:44:05 -04:00
committed by GitHub
parent 6f227c31e2
commit d4b0058372
22 changed files with 10106 additions and 12 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,84 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.PostgresMigrations.Migrations;
/// <inheritdoc />
public partial class OrganizationIntegrations : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "OrganizationIntegration",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
OrganizationId = table.Column<Guid>(type: "uuid", nullable: false),
Type = table.Column<int>(type: "integer", nullable: false),
Configuration = table.Column<string>(type: "text", nullable: true),
CreationDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
RevisionDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_OrganizationIntegration", x => x.Id);
table.ForeignKey(
name: "FK_OrganizationIntegration_Organization_OrganizationId",
column: x => x.OrganizationId,
principalTable: "Organization",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "OrganizationIntegrationConfiguration",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
OrganizationIntegrationId = table.Column<Guid>(type: "uuid", nullable: false),
EventType = table.Column<int>(type: "integer", nullable: false),
Configuration = table.Column<string>(type: "text", nullable: true),
Template = table.Column<string>(type: "text", nullable: true),
CreationDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
RevisionDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_OrganizationIntegrationConfiguration", x => x.Id);
table.ForeignKey(
name: "FK_OrganizationIntegrationConfiguration_OrganizationIntegratio~",
column: x => x.OrganizationIntegrationId,
principalTable: "OrganizationIntegration",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_OrganizationIntegration_OrganizationId",
table: "OrganizationIntegration",
column: "OrganizationId");
migrationBuilder.CreateIndex(
name: "IX_OrganizationIntegration_OrganizationId_Type",
table: "OrganizationIntegration",
columns: new[] { "OrganizationId", "Type" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_OrganizationIntegrationConfiguration_OrganizationIntegratio~",
table: "OrganizationIntegrationConfiguration",
column: "OrganizationIntegrationId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "OrganizationIntegrationConfiguration");
migrationBuilder.DropTable(
name: "OrganizationIntegration");
}
}

View File

@ -220,6 +220,68 @@ namespace Bit.PostgresMigrations.Migrations
b.ToTable("Organization", (string)null);
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.AdminConsole.Models.OrganizationIntegration", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<string>("Configuration")
.HasColumnType("text");
b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("OrganizationId")
.HasColumnType("uuid");
b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone");
b.Property<int>("Type")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("OrganizationId")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("OrganizationId", "Type")
.IsUnique()
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("OrganizationIntegration", (string)null);
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.AdminConsole.Models.OrganizationIntegrationConfiguration", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<string>("Configuration")
.HasColumnType("text");
b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone");
b.Property<int>("EventType")
.HasColumnType("integer");
b.Property<Guid>("OrganizationIntegrationId")
.HasColumnType("uuid");
b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Template")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("OrganizationIntegrationId");
b.ToTable("OrganizationIntegrationConfiguration", (string)null);
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.AdminConsole.Models.Policy", b =>
{
b.Property<Guid>("Id")
@ -410,10 +472,6 @@ namespace Bit.PostgresMigrations.Migrations
b.Property<DateTime?>("AuthenticationDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("RequestCountryName")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone");
@ -429,6 +487,10 @@ namespace Bit.PostgresMigrations.Migrations
b.Property<string>("PublicKey")
.HasColumnType("text");
b.Property<string>("RequestCountryName")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("RequestDeviceIdentifier")
.HasMaxLength(50)
.HasColumnType("character varying(50)");
@ -2265,6 +2327,28 @@ namespace Bit.PostgresMigrations.Migrations
b.HasDiscriminator().HasValue("user_service_account");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.AdminConsole.Models.OrganizationIntegration", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.AdminConsole.Models.Organization", "Organization")
.WithMany()
.HasForeignKey("OrganizationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Organization");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.AdminConsole.Models.OrganizationIntegrationConfiguration", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.AdminConsole.Models.OrganizationIntegration", "OrganizationIntegration")
.WithMany()
.HasForeignKey("OrganizationIntegrationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("OrganizationIntegration");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.AdminConsole.Models.Policy", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.AdminConsole.Models.Organization", "Organization")