1
0
mirror of https://github.com/bitwarden/server synced 2025-12-06 00:03:34 +00:00
Files
server/util/MySqlMigrations/Migrations/20251009152659_CreatingSecretVersionTables.cs
cd-bitwarden 2965b499e9 [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
2025-10-16 15:35:14 -04:00

72 lines
2.9 KiB
C#

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");
}
}