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:
28
src/Core/SecretsManager/Entities/SecretVersion.cs
Normal file
28
src/Core/SecretsManager/Entities/SecretVersion.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
#nullable enable
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.SecretsManager.Entities;
|
||||
|
||||
public class SecretVersion : ITableObject<Guid>
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public Guid SecretId { get; set; }
|
||||
|
||||
public string Value { get; set; } = string.Empty;
|
||||
|
||||
public DateTime VersionDate { get; set; }
|
||||
|
||||
public Guid? EditorServiceAccountId { get; set; }
|
||||
|
||||
public Guid? EditorOrganizationUserId { get; set; }
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
if (Id == default(Guid))
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,6 +63,7 @@ public class DatabaseContext : DbContext
|
||||
public DbSet<Policy> Policies { get; set; }
|
||||
public DbSet<Provider> Providers { get; set; }
|
||||
public DbSet<Secret> Secret { get; set; }
|
||||
public DbSet<SecretVersion> SecretVersion { get; set; }
|
||||
public DbSet<ServiceAccount> ServiceAccount { get; set; }
|
||||
public DbSet<Project> Project { get; set; }
|
||||
public DbSet<ProviderUser> ProviderUsers { get; set; }
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
using Bit.Infrastructure.EntityFramework.SecretsManager.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.SecretsManager.Configurations;
|
||||
|
||||
public class SecretVersionEntityTypeConfiguration : IEntityTypeConfiguration<SecretVersion>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<SecretVersion> builder)
|
||||
{
|
||||
builder.Property(sv => sv.Id)
|
||||
.ValueGeneratedNever();
|
||||
|
||||
builder.HasKey(sv => sv.Id)
|
||||
.IsClustered();
|
||||
|
||||
builder.Property(sv => sv.Value)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(sv => sv.VersionDate)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(sv => sv.EditorServiceAccount)
|
||||
.WithMany()
|
||||
.HasForeignKey(sv => sv.EditorServiceAccountId)
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
|
||||
builder.HasOne(sv => sv.EditorOrganizationUser)
|
||||
.WithMany()
|
||||
.HasForeignKey(sv => sv.EditorOrganizationUserId)
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
|
||||
builder.HasIndex(sv => sv.SecretId)
|
||||
.HasDatabaseName("IX_SecretVersion_SecretId");
|
||||
|
||||
builder.HasIndex(sv => sv.EditorServiceAccountId)
|
||||
.HasDatabaseName("IX_SecretVersion_EditorServiceAccountId");
|
||||
|
||||
builder.HasIndex(sv => sv.EditorOrganizationUserId)
|
||||
.HasDatabaseName("IX_SecretVersion_EditorOrganizationUserId");
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ public class Secret : Core.SecretsManager.Entities.Secret
|
||||
public virtual ICollection<UserSecretAccessPolicy> UserAccessPolicies { get; set; }
|
||||
public virtual ICollection<GroupSecretAccessPolicy> GroupAccessPolicies { get; set; }
|
||||
public virtual ICollection<ServiceAccountSecretAccessPolicy> ServiceAccountAccessPolicies { get; set; }
|
||||
public virtual ICollection<SecretVersion> SecretVersions { get; set; }
|
||||
}
|
||||
|
||||
public class SecretMapperProfile : Profile
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#nullable enable
|
||||
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.SecretsManager.Models;
|
||||
|
||||
public class SecretVersion : Core.SecretsManager.Entities.SecretVersion
|
||||
{
|
||||
public Secret? Secret { get; set; }
|
||||
|
||||
public ServiceAccount? EditorServiceAccount { get; set; }
|
||||
|
||||
public Bit.Infrastructure.EntityFramework.Models.OrganizationUser? EditorOrganizationUser { get; set; }
|
||||
}
|
||||
|
||||
public class SecretVersionMapperProfile : Profile
|
||||
{
|
||||
public SecretVersionMapperProfile()
|
||||
{
|
||||
CreateMap<Core.SecretsManager.Entities.SecretVersion, SecretVersion>()
|
||||
.PreserveReferences()
|
||||
.ReverseMap();
|
||||
}
|
||||
}
|
||||
27
src/Sql/dbo/SecretsManager/Tables/SecretVersion.sql
Normal file
27
src/Sql/dbo/SecretsManager/Tables/SecretVersion.sql
Normal file
@@ -0,0 +1,27 @@
|
||||
CREATE TABLE [dbo].[SecretVersion] (
|
||||
[Id] UNIQUEIDENTIFIER NOT NULL,
|
||||
[SecretId] UNIQUEIDENTIFIER NOT NULL,
|
||||
[Value] NVARCHAR (MAX) NOT NULL,
|
||||
[VersionDate] DATETIME2 (7) NOT NULL,
|
||||
[EditorServiceAccountId] UNIQUEIDENTIFIER NULL,
|
||||
[EditorOrganizationUserId] UNIQUEIDENTIFIER NULL,
|
||||
CONSTRAINT [PK_SecretVersion] PRIMARY KEY CLUSTERED ([Id] ASC),
|
||||
CONSTRAINT [FK_SecretVersion_OrganizationUser] FOREIGN KEY ([EditorOrganizationUserId]) REFERENCES [dbo].[OrganizationUser] ([Id]) ON DELETE SET NULL,
|
||||
CONSTRAINT [FK_SecretVersion_Secret] FOREIGN KEY ([SecretId]) REFERENCES [dbo].[Secret] ([Id]) ON DELETE CASCADE,
|
||||
CONSTRAINT [FK_SecretVersion_ServiceAccount] FOREIGN KEY ([EditorServiceAccountId]) REFERENCES [dbo].[ServiceAccount] ([Id]) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
GO
|
||||
CREATE NONCLUSTERED INDEX [IX_SecretVersion_SecretId]
|
||||
ON [dbo].[SecretVersion]([SecretId] ASC);
|
||||
|
||||
GO
|
||||
CREATE NONCLUSTERED INDEX [IX_SecretVersion_EditorServiceAccountId]
|
||||
ON [dbo].[SecretVersion]([EditorServiceAccountId] ASC)
|
||||
WHERE [EditorServiceAccountId] IS NOT NULL;
|
||||
|
||||
GO
|
||||
CREATE NONCLUSTERED INDEX [IX_SecretVersion_EditorOrganizationUserId]
|
||||
ON [dbo].[SecretVersion]([EditorOrganizationUserId] ASC)
|
||||
WHERE [EditorOrganizationUserId] IS NOT NULL;
|
||||
GO
|
||||
@@ -0,0 +1,83 @@
|
||||
SET ANSI_NULLS ON;
|
||||
SET QUOTED_IDENTIFIER ON;
|
||||
GO
|
||||
|
||||
IF NOT EXISTS (SELECT 1 FROM sys.tables WHERE name = 'SecretVersion' AND schema_id = SCHEMA_ID('dbo'))
|
||||
BEGIN
|
||||
CREATE TABLE [dbo].[SecretVersion] (
|
||||
[Id] UNIQUEIDENTIFIER NOT NULL,
|
||||
[SecretId] UNIQUEIDENTIFIER NOT NULL,
|
||||
[Value] NVARCHAR (MAX) NOT NULL,
|
||||
[VersionDate] DATETIME2 (7) NOT NULL,
|
||||
[EditorServiceAccountId] UNIQUEIDENTIFIER NULL,
|
||||
[EditorOrganizationUserId] UNIQUEIDENTIFIER NULL,
|
||||
CONSTRAINT [PK_SecretVersion] PRIMARY KEY CLUSTERED ([Id] ASC)
|
||||
);
|
||||
END
|
||||
GO
|
||||
|
||||
-- Ensure foreign keys exist
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM sys.foreign_keys WHERE name = 'FK_SecretVersion_OrganizationUser'
|
||||
)
|
||||
BEGIN
|
||||
ALTER TABLE [dbo].[SecretVersion]
|
||||
ADD CONSTRAINT [FK_SecretVersion_OrganizationUser]
|
||||
FOREIGN KEY ([EditorOrganizationUserId])
|
||||
REFERENCES [dbo].[OrganizationUser] ([Id])
|
||||
ON DELETE SET NULL;
|
||||
END
|
||||
GO
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM sys.foreign_keys WHERE name = 'FK_SecretVersion_Secret'
|
||||
)
|
||||
BEGIN
|
||||
ALTER TABLE [dbo].[SecretVersion]
|
||||
ADD CONSTRAINT [FK_SecretVersion_Secret]
|
||||
FOREIGN KEY ([SecretId])
|
||||
REFERENCES [dbo].[Secret] ([Id])
|
||||
ON DELETE CASCADE;
|
||||
END
|
||||
GO
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM sys.foreign_keys WHERE name = 'FK_SecretVersion_ServiceAccount'
|
||||
)
|
||||
BEGIN
|
||||
ALTER TABLE [dbo].[SecretVersion]
|
||||
ADD CONSTRAINT [FK_SecretVersion_ServiceAccount]
|
||||
FOREIGN KEY ([EditorServiceAccountId])
|
||||
REFERENCES [dbo].[ServiceAccount] ([Id])
|
||||
ON DELETE SET NULL;
|
||||
END
|
||||
GO
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM sys.indexes WHERE name = 'IX_SecretVersion_SecretId' AND object_id = OBJECT_ID('[dbo].[SecretVersion]')
|
||||
)
|
||||
BEGIN
|
||||
CREATE NONCLUSTERED INDEX [IX_SecretVersion_SecretId]
|
||||
ON [dbo].[SecretVersion]([SecretId] ASC);
|
||||
END
|
||||
GO
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM sys.indexes WHERE name = 'IX_SecretVersion_EditorServiceAccountId' AND object_id = OBJECT_ID('[dbo].[SecretVersion]')
|
||||
)
|
||||
BEGIN
|
||||
CREATE NONCLUSTERED INDEX [IX_SecretVersion_EditorServiceAccountId]
|
||||
ON [dbo].[SecretVersion]([EditorServiceAccountId] ASC)
|
||||
WHERE [EditorServiceAccountId] IS NOT NULL;
|
||||
END
|
||||
GO
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM sys.indexes WHERE name = 'IX_SecretVersion_EditorOrganizationUserId' AND object_id = OBJECT_ID('[dbo].[SecretVersion]')
|
||||
)
|
||||
BEGIN
|
||||
CREATE NONCLUSTERED INDEX [IX_SecretVersion_EditorOrganizationUserId]
|
||||
ON [dbo].[SecretVersion]([EditorOrganizationUserId] ASC)
|
||||
WHERE [EditorOrganizationUserId] IS NOT NULL;
|
||||
END
|
||||
GO
|
||||
3347
util/MySqlMigrations/Migrations/20251009152659_CreatingSecretVersionTables.Designer.cs
generated
Normal file
3347
util/MySqlMigrations/Migrations/20251009152659_CreatingSecretVersionTables.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,71 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bit.MySqlMigrations.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: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
SecretId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Value = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
VersionDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
EditorServiceAccountId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||
EditorOrganizationUserId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci")
|
||||
},
|
||||
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);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -2159,6 +2159,42 @@ namespace Bit.MySqlMigrations.Migrations
|
||||
b.ToTable("Secret", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.SecretsManager.Models.SecretVersion", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid?>("EditorOrganizationUserId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid?>("EditorServiceAccountId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("SecretId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime>("VersionDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
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")
|
||||
@@ -2984,6 +3020,31 @@ namespace Bit.MySqlMigrations.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")
|
||||
@@ -3255,6 +3316,8 @@ namespace Bit.MySqlMigrations.Migrations
|
||||
{
|
||||
b.Navigation("GroupAccessPolicies");
|
||||
|
||||
b.Navigation("SecretVersions");
|
||||
|
||||
b.Navigation("ServiceAccountAccessPolicies");
|
||||
|
||||
b.Navigation("UserAccessPolicies");
|
||||
|
||||
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");
|
||||
|
||||
3336
util/SqliteMigrations/Migrations/20251009152635_CreatingSecretVersionTables.Designer.cs
generated
Normal file
3336
util/SqliteMigrations/Migrations/20251009152635_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.SqliteMigrations.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: "TEXT", nullable: false),
|
||||
SecretId = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||
Value = table.Column<string>(type: "TEXT", nullable: false),
|
||||
VersionDate = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||
EditorServiceAccountId = table.Column<Guid>(type: "TEXT", nullable: true),
|
||||
EditorOrganizationUserId = table.Column<Guid>(type: "TEXT", 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");
|
||||
}
|
||||
}
|
||||
@@ -2148,6 +2148,42 @@ namespace Bit.SqliteMigrations.Migrations
|
||||
b.ToTable("Secret", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.SecretsManager.Models.SecretVersion", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid?>("EditorOrganizationUserId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid?>("EditorServiceAccountId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("SecretId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("VersionDate")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
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")
|
||||
@@ -2973,6 +3009,31 @@ namespace Bit.SqliteMigrations.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")
|
||||
@@ -3244,6 +3305,8 @@ namespace Bit.SqliteMigrations.Migrations
|
||||
{
|
||||
b.Navigation("GroupAccessPolicies");
|
||||
|
||||
b.Navigation("SecretVersions");
|
||||
|
||||
b.Navigation("ServiceAccountAccessPolicies");
|
||||
|
||||
b.Navigation("UserAccessPolicies");
|
||||
|
||||
Reference in New Issue
Block a user