mirror of
https://github.com/bitwarden/server
synced 2025-12-06 00:03:34 +00:00
[SM-1591] Adding SecretVersion table to server (#6406)
* Adding SecretVersion table to server * making the names singular not plural for new table * removing migration * fixing migration * Adding indexes for serviceacct and orguserId * indexes for sqllite * fixing migrations * adding indexes to secretVeriosn.sql * tests * removing tests * adding GO
This commit is contained in:
3353
util/PostgresMigrations/Migrations/20251009152612_CreatingSecretVersionTables.Designer.cs
generated
Normal file
3353
util/PostgresMigrations/Migrations/20251009152612_CreatingSecretVersionTables.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,69 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bit.PostgresMigrations.Migrations;
|
||||
|
||||
/// <inheritdoc />
|
||||
public partial class CreatingSecretVersionTables : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SecretVersion",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
SecretId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Value = table.Column<string>(type: "text", nullable: false),
|
||||
VersionDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
EditorServiceAccountId = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
EditorOrganizationUserId = table.Column<Guid>(type: "uuid", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SecretVersion", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_SecretVersion_OrganizationUser_EditorOrganizationUserId",
|
||||
column: x => x.EditorOrganizationUserId,
|
||||
principalTable: "OrganizationUser",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.SetNull);
|
||||
table.ForeignKey(
|
||||
name: "FK_SecretVersion_Secret_SecretId",
|
||||
column: x => x.SecretId,
|
||||
principalTable: "Secret",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_SecretVersion_ServiceAccount_EditorServiceAccountId",
|
||||
column: x => x.EditorServiceAccountId,
|
||||
principalTable: "ServiceAccount",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.SetNull);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SecretVersion_EditorOrganizationUserId",
|
||||
table: "SecretVersion",
|
||||
column: "EditorOrganizationUserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SecretVersion_EditorServiceAccountId",
|
||||
table: "SecretVersion",
|
||||
column: "EditorServiceAccountId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SecretVersion_SecretId",
|
||||
table: "SecretVersion",
|
||||
column: "SecretId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "SecretVersion");
|
||||
}
|
||||
}
|
||||
@@ -2165,6 +2165,42 @@ namespace Bit.PostgresMigrations.Migrations
|
||||
b.ToTable("Secret", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.SecretsManager.Models.SecretVersion", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid?>("EditorOrganizationUserId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid?>("EditorServiceAccountId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("SecretId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("VersionDate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasAnnotation("SqlServer:Clustered", true);
|
||||
|
||||
b.HasIndex("EditorOrganizationUserId")
|
||||
.HasDatabaseName("IX_SecretVersion_EditorOrganizationUserId");
|
||||
|
||||
b.HasIndex("EditorServiceAccountId")
|
||||
.HasDatabaseName("IX_SecretVersion_EditorServiceAccountId");
|
||||
|
||||
b.HasIndex("SecretId")
|
||||
.HasDatabaseName("IX_SecretVersion_SecretId");
|
||||
|
||||
b.ToTable("SecretVersion");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.SecretsManager.Models.ServiceAccount", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@@ -2990,6 +3026,31 @@ namespace Bit.PostgresMigrations.Migrations
|
||||
b.Navigation("Organization");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.SecretsManager.Models.SecretVersion", b =>
|
||||
{
|
||||
b.HasOne("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", "EditorOrganizationUser")
|
||||
.WithMany()
|
||||
.HasForeignKey("EditorOrganizationUserId")
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
|
||||
b.HasOne("Bit.Infrastructure.EntityFramework.SecretsManager.Models.ServiceAccount", "EditorServiceAccount")
|
||||
.WithMany()
|
||||
.HasForeignKey("EditorServiceAccountId")
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
|
||||
b.HasOne("Bit.Infrastructure.EntityFramework.SecretsManager.Models.Secret", "Secret")
|
||||
.WithMany("SecretVersions")
|
||||
.HasForeignKey("SecretId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("EditorOrganizationUser");
|
||||
|
||||
b.Navigation("EditorServiceAccount");
|
||||
|
||||
b.Navigation("Secret");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.SecretsManager.Models.ServiceAccount", b =>
|
||||
{
|
||||
b.HasOne("Bit.Infrastructure.EntityFramework.AdminConsole.Models.Organization", "Organization")
|
||||
@@ -3261,6 +3322,8 @@ namespace Bit.PostgresMigrations.Migrations
|
||||
{
|
||||
b.Navigation("GroupAccessPolicies");
|
||||
|
||||
b.Navigation("SecretVersions");
|
||||
|
||||
b.Navigation("ServiceAccountAccessPolicies");
|
||||
|
||||
b.Navigation("UserAccessPolicies");
|
||||
|
||||
Reference in New Issue
Block a user