From 1ebfac18a26add1d8d0a108ec6cda41ad883ece3 Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Mon, 17 Nov 2025 14:45:38 -0800 Subject: [PATCH] fixup seededData vs playData migrations --- .../QueryControllerTest.cs | 18 ---- .../20251105002110_2025-11-04_00_PlayData.cs | 101 ------------------ ...cs => 20251117210114_PlayData.Designer.cs} | 62 ++++++----- .../Migrations/20251117210114_PlayData.cs | 98 +++++++++++++++++ .../DatabaseContextModelSnapshot.cs | 22 ---- .../20251105002123_2025-11-04_00_PlayData.cs | 96 ----------------- ...cs => 20251117210121_PlayData.Designer.cs} | 62 ++++++----- .../Migrations/20251117210121_PlayData.cs | 96 +++++++++++++++++ .../DatabaseContextModelSnapshot.cs | 22 ---- .../20251105002117_2025-11-04_00_PlayData.cs | 80 -------------- ...cs => 20251117210127_PlayData.Designer.cs} | 62 ++++++----- .../Migrations/20251117210127_PlayData.cs | 96 +++++++++++++++++ .../DatabaseContextModelSnapshot.cs | 22 ---- 13 files changed, 404 insertions(+), 433 deletions(-) delete mode 100644 util/MySqlMigrations/Migrations/20251105002110_2025-11-04_00_PlayData.cs rename util/MySqlMigrations/Migrations/{20251105002110_2025-11-04_00_PlayData.Designer.cs => 20251117210114_PlayData.Designer.cs} (98%) create mode 100644 util/MySqlMigrations/Migrations/20251117210114_PlayData.cs delete mode 100644 util/PostgresMigrations/Migrations/20251105002123_2025-11-04_00_PlayData.cs rename util/PostgresMigrations/Migrations/{20251105002123_2025-11-04_00_PlayData.Designer.cs => 20251117210121_PlayData.Designer.cs} (98%) create mode 100644 util/PostgresMigrations/Migrations/20251117210121_PlayData.cs delete mode 100644 util/SqliteMigrations/Migrations/20251105002117_2025-11-04_00_PlayData.cs rename util/SqliteMigrations/Migrations/{20251105002117_2025-11-04_00_PlayData.Designer.cs => 20251117210127_PlayData.Designer.cs} (98%) create mode 100644 util/SqliteMigrations/Migrations/20251117210127_PlayData.cs diff --git a/test/SeederApi.IntegrationTest/QueryControllerTest.cs b/test/SeederApi.IntegrationTest/QueryControllerTest.cs index 2bba92786d..571181e49f 100644 --- a/test/SeederApi.IntegrationTest/QueryControllerTest.cs +++ b/test/SeederApi.IntegrationTest/QueryControllerTest.cs @@ -72,22 +72,4 @@ public class QueryControllerTests : IClassFixture, Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); } - - [Fact] - public async Task QueryEndpoint_VerifyQueryDoesNotCreateSeedId() - { - var testEmail = $"test-{Guid.NewGuid()}@bitwarden.com"; - - var response = await _client.PostAsJsonAsync("/query", new QueryRequestModel - { - Template = "EmergencyAccessInviteQuery", - Arguments = System.Text.Json.JsonSerializer.SerializeToElement(new { email = testEmail }) - }); - - response.EnsureSuccessStatusCode(); - var result = await response.Content.ReadAsStringAsync(); - - Assert.Equal("[]", result); - } - } diff --git a/util/MySqlMigrations/Migrations/20251105002110_2025-11-04_00_PlayData.cs b/util/MySqlMigrations/Migrations/20251105002110_2025-11-04_00_PlayData.cs deleted file mode 100644 index 2492a3470d..0000000000 --- a/util/MySqlMigrations/Migrations/20251105002110_2025-11-04_00_PlayData.cs +++ /dev/null @@ -1,101 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Bit.MySqlMigrations.Migrations; - -/// -public partial class _20251104_00_PlayData : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "WaitTimeDays", - table: "EmergencyAccess", - type: "smallint", - nullable: false, - oldClrType: typeof(int), - oldType: "int"); - - migrationBuilder.CreateTable( - name: "PlayData", - columns: table => new - { - Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), - PlayId = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - UserId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), - OrganizationId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), - CreationDate = table.Column(type: "datetime(6)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_PlayData", x => x.Id); - table.CheckConstraint("CK_PlayData_UserOrOrganization", "([UserId] IS NOT NULL AND [OrganizationId] IS NULL) OR ([UserId] IS NULL AND [OrganizationId] IS NOT NULL)"); - table.ForeignKey( - name: "FK_PlayData_Organization_OrganizationId", - column: x => x.OrganizationId, - principalTable: "Organization", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_PlayData_User_UserId", - column: x => x.UserId, - principalTable: "User", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "SeededData", - columns: table => new - { - Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), - RecipeName = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Data = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - CreationDate = table.Column(type: "datetime(6)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_SeededData", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_PlayData_OrganizationId", - table: "PlayData", - column: "OrganizationId"); - - migrationBuilder.CreateIndex( - name: "IX_PlayData_PlayId", - table: "PlayData", - column: "PlayId"); - - migrationBuilder.CreateIndex( - name: "IX_PlayData_UserId", - table: "PlayData", - column: "UserId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "PlayData"); - - migrationBuilder.DropTable( - name: "SeededData"); - - migrationBuilder.AlterColumn( - name: "WaitTimeDays", - table: "EmergencyAccess", - type: "int", - nullable: false, - oldClrType: typeof(short), - oldType: "smallint"); - } -} diff --git a/util/MySqlMigrations/Migrations/20251105002110_2025-11-04_00_PlayData.Designer.cs b/util/MySqlMigrations/Migrations/20251117210114_PlayData.Designer.cs similarity index 98% rename from util/MySqlMigrations/Migrations/20251105002110_2025-11-04_00_PlayData.Designer.cs rename to util/MySqlMigrations/Migrations/20251117210114_PlayData.Designer.cs index 021bc0e70e..66dab6223b 100644 --- a/util/MySqlMigrations/Migrations/20251105002110_2025-11-04_00_PlayData.Designer.cs +++ b/util/MySqlMigrations/Migrations/20251117210114_PlayData.Designer.cs @@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Bit.MySqlMigrations.Migrations { [DbContext(typeof(DatabaseContext))] - [Migration("20251105002110_2025-11-04_00_PlayData")] - partial class _20251104_00_PlayData + [Migration("20251117210114_PlayData")] + partial class PlayData { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -1017,6 +1017,12 @@ namespace Bit.MySqlMigrations.Migrations b.Property("Id") .HasColumnType("char(36)"); + b.Property("ApplicationAtRiskCount") + .HasColumnType("int"); + + b.Property("ApplicationCount") + .HasColumnType("int"); + b.Property("ApplicationData") .HasColumnType("longtext"); @@ -1027,9 +1033,39 @@ namespace Bit.MySqlMigrations.Migrations b.Property("CreationDate") .HasColumnType("datetime(6)"); + b.Property("CriticalApplicationAtRiskCount") + .HasColumnType("int"); + + b.Property("CriticalApplicationCount") + .HasColumnType("int"); + + b.Property("CriticalMemberAtRiskCount") + .HasColumnType("int"); + + b.Property("CriticalMemberCount") + .HasColumnType("int"); + + b.Property("CriticalPasswordAtRiskCount") + .HasColumnType("int"); + + b.Property("CriticalPasswordCount") + .HasColumnType("int"); + + b.Property("MemberAtRiskCount") + .HasColumnType("int"); + + b.Property("MemberCount") + .HasColumnType("int"); + b.Property("OrganizationId") .HasColumnType("char(36)"); + b.Property("PasswordAtRiskCount") + .HasColumnType("int"); + + b.Property("PasswordCount") + .HasColumnType("int"); + b.Property("ReportData") .IsRequired() .HasColumnType("longtext"); @@ -1624,28 +1660,6 @@ namespace Bit.MySqlMigrations.Migrations }); }); - modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SeededData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("CreationDate") - .HasColumnType("datetime(6)"); - - b.Property("Data") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("RecipeName") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("SeededData"); - }); - modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Send", b => { b.Property("Id") diff --git a/util/MySqlMigrations/Migrations/20251117210114_PlayData.cs b/util/MySqlMigrations/Migrations/20251117210114_PlayData.cs new file mode 100644 index 0000000000..d83ae79298 --- /dev/null +++ b/util/MySqlMigrations/Migrations/20251117210114_PlayData.cs @@ -0,0 +1,98 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Bit.MySqlMigrations.Migrations; + +/// +public partial class PlayData : Migration +{ + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Id", + table: "PlayData", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "CreationDate", + table: "PlayData", + type: "datetime(6)", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "PlayId", + table: "PlayData", + type: "varchar(256)", + maxLength: 256, + nullable: false, + defaultValue: "") + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AddPrimaryKey( + name: "PK_PlayData", + table: "PlayData", + column: "Id"); + + migrationBuilder.CreateIndex( + name: "IX_PlayData_OrganizationId", + table: "PlayData", + column: "OrganizationId"); + + migrationBuilder.CreateIndex( + name: "IX_PlayData_PlayId", + table: "PlayData", + column: "PlayId"); + + migrationBuilder.CreateIndex( + name: "IX_PlayData_UserId", + table: "PlayData", + column: "UserId"); + + migrationBuilder.AddCheckConstraint( + name: "CK_PlayData_UserOrOrganization", + table: "PlayData", + sql: "([UserId] IS NOT NULL AND [OrganizationId] IS NULL) OR ([UserId] IS NULL AND [OrganizationId] IS NOT NULL)"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_PlayData", + table: "PlayData"); + + migrationBuilder.DropIndex( + name: "IX_PlayData_OrganizationId", + table: "PlayData"); + + migrationBuilder.DropIndex( + name: "IX_PlayData_PlayId", + table: "PlayData"); + + migrationBuilder.DropIndex( + name: "IX_PlayData_UserId", + table: "PlayData"); + + migrationBuilder.DropCheckConstraint( + name: "CK_PlayData_UserOrOrganization", + table: "PlayData"); + + migrationBuilder.DropColumn( + name: "Id", + table: "PlayData"); + + migrationBuilder.DropColumn( + name: "CreationDate", + table: "PlayData"); + + migrationBuilder.DropColumn( + name: "PlayId", + table: "PlayData"); + } +} diff --git a/util/MySqlMigrations/Migrations/DatabaseContextModelSnapshot.cs b/util/MySqlMigrations/Migrations/DatabaseContextModelSnapshot.cs index 6d58d1b413..afdf379896 100644 --- a/util/MySqlMigrations/Migrations/DatabaseContextModelSnapshot.cs +++ b/util/MySqlMigrations/Migrations/DatabaseContextModelSnapshot.cs @@ -1657,28 +1657,6 @@ namespace Bit.MySqlMigrations.Migrations }); }); - modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SeededData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); - - b.Property("CreationDate") - .HasColumnType("datetime(6)"); - - b.Property("Data") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("RecipeName") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("SeededData"); - }); - modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Send", b => { b.Property("Id") diff --git a/util/PostgresMigrations/Migrations/20251105002123_2025-11-04_00_PlayData.cs b/util/PostgresMigrations/Migrations/20251105002123_2025-11-04_00_PlayData.cs deleted file mode 100644 index ba4e373d22..0000000000 --- a/util/PostgresMigrations/Migrations/20251105002123_2025-11-04_00_PlayData.cs +++ /dev/null @@ -1,96 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Bit.PostgresMigrations.Migrations; - -/// -public partial class _20251104_00_PlayData : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "WaitTimeDays", - table: "EmergencyAccess", - type: "smallint", - nullable: false, - oldClrType: typeof(int), - oldType: "integer"); - - migrationBuilder.CreateTable( - name: "PlayData", - columns: table => new - { - Id = table.Column(type: "uuid", nullable: false), - PlayId = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), - UserId = table.Column(type: "uuid", nullable: true), - OrganizationId = table.Column(type: "uuid", nullable: true), - CreationDate = table.Column(type: "timestamp with time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_PlayData", x => x.Id); - table.CheckConstraint("CK_PlayData_UserOrOrganization", "([UserId] IS NOT NULL AND [OrganizationId] IS NULL) OR ([UserId] IS NULL AND [OrganizationId] IS NOT NULL)"); - table.ForeignKey( - name: "FK_PlayData_Organization_OrganizationId", - column: x => x.OrganizationId, - principalTable: "Organization", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_PlayData_User_UserId", - column: x => x.UserId, - principalTable: "User", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "SeededData", - columns: table => new - { - Id = table.Column(type: "uuid", nullable: false), - RecipeName = table.Column(type: "text", nullable: false), - Data = table.Column(type: "text", nullable: false), - CreationDate = table.Column(type: "timestamp with time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_SeededData", x => x.Id); - }); - - migrationBuilder.CreateIndex( - name: "IX_PlayData_OrganizationId", - table: "PlayData", - column: "OrganizationId"); - - migrationBuilder.CreateIndex( - name: "IX_PlayData_PlayId", - table: "PlayData", - column: "PlayId"); - - migrationBuilder.CreateIndex( - name: "IX_PlayData_UserId", - table: "PlayData", - column: "UserId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "PlayData"); - - migrationBuilder.DropTable( - name: "SeededData"); - - migrationBuilder.AlterColumn( - name: "WaitTimeDays", - table: "EmergencyAccess", - type: "integer", - nullable: false, - oldClrType: typeof(short), - oldType: "smallint"); - } -} diff --git a/util/PostgresMigrations/Migrations/20251105002123_2025-11-04_00_PlayData.Designer.cs b/util/PostgresMigrations/Migrations/20251117210121_PlayData.Designer.cs similarity index 98% rename from util/PostgresMigrations/Migrations/20251105002123_2025-11-04_00_PlayData.Designer.cs rename to util/PostgresMigrations/Migrations/20251117210121_PlayData.Designer.cs index 786b5c7c59..fea38b8c1c 100644 --- a/util/PostgresMigrations/Migrations/20251105002123_2025-11-04_00_PlayData.Designer.cs +++ b/util/PostgresMigrations/Migrations/20251117210121_PlayData.Designer.cs @@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace Bit.PostgresMigrations.Migrations { [DbContext(typeof(DatabaseContext))] - [Migration("20251105002123_2025-11-04_00_PlayData")] - partial class _20251104_00_PlayData + [Migration("20251117210121_PlayData")] + partial class PlayData { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -1022,6 +1022,12 @@ namespace Bit.PostgresMigrations.Migrations b.Property("Id") .HasColumnType("uuid"); + b.Property("ApplicationAtRiskCount") + .HasColumnType("integer"); + + b.Property("ApplicationCount") + .HasColumnType("integer"); + b.Property("ApplicationData") .HasColumnType("text"); @@ -1032,9 +1038,39 @@ namespace Bit.PostgresMigrations.Migrations b.Property("CreationDate") .HasColumnType("timestamp with time zone"); + b.Property("CriticalApplicationAtRiskCount") + .HasColumnType("integer"); + + b.Property("CriticalApplicationCount") + .HasColumnType("integer"); + + b.Property("CriticalMemberAtRiskCount") + .HasColumnType("integer"); + + b.Property("CriticalMemberCount") + .HasColumnType("integer"); + + b.Property("CriticalPasswordAtRiskCount") + .HasColumnType("integer"); + + b.Property("CriticalPasswordCount") + .HasColumnType("integer"); + + b.Property("MemberAtRiskCount") + .HasColumnType("integer"); + + b.Property("MemberCount") + .HasColumnType("integer"); + b.Property("OrganizationId") .HasColumnType("uuid"); + b.Property("PasswordAtRiskCount") + .HasColumnType("integer"); + + b.Property("PasswordCount") + .HasColumnType("integer"); + b.Property("ReportData") .IsRequired() .HasColumnType("text"); @@ -1629,28 +1665,6 @@ namespace Bit.PostgresMigrations.Migrations }); }); - modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SeededData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreationDate") - .HasColumnType("timestamp with time zone"); - - b.Property("Data") - .IsRequired() - .HasColumnType("text"); - - b.Property("RecipeName") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("SeededData"); - }); - modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Send", b => { b.Property("Id") diff --git a/util/PostgresMigrations/Migrations/20251117210121_PlayData.cs b/util/PostgresMigrations/Migrations/20251117210121_PlayData.cs new file mode 100644 index 0000000000..8da97546cc --- /dev/null +++ b/util/PostgresMigrations/Migrations/20251117210121_PlayData.cs @@ -0,0 +1,96 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Bit.PostgresMigrations.Migrations; + +/// +public partial class PlayData : Migration +{ + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Id", + table: "PlayData", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "CreationDate", + table: "PlayData", + type: "timestamp with time zone", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "PlayId", + table: "PlayData", + type: "character varying(256)", + maxLength: 256, + nullable: false, + defaultValue: ""); + + migrationBuilder.AddPrimaryKey( + name: "PK_PlayData", + table: "PlayData", + column: "Id"); + + migrationBuilder.CreateIndex( + name: "IX_PlayData_OrganizationId", + table: "PlayData", + column: "OrganizationId"); + + migrationBuilder.CreateIndex( + name: "IX_PlayData_PlayId", + table: "PlayData", + column: "PlayId"); + + migrationBuilder.CreateIndex( + name: "IX_PlayData_UserId", + table: "PlayData", + column: "UserId"); + + migrationBuilder.AddCheckConstraint( + name: "CK_PlayData_UserOrOrganization", + table: "PlayData", + sql: "([UserId] IS NOT NULL AND [OrganizationId] IS NULL) OR ([UserId] IS NULL AND [OrganizationId] IS NOT NULL)"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_PlayData", + table: "PlayData"); + + migrationBuilder.DropIndex( + name: "IX_PlayData_OrganizationId", + table: "PlayData"); + + migrationBuilder.DropIndex( + name: "IX_PlayData_PlayId", + table: "PlayData"); + + migrationBuilder.DropIndex( + name: "IX_PlayData_UserId", + table: "PlayData"); + + migrationBuilder.DropCheckConstraint( + name: "CK_PlayData_UserOrOrganization", + table: "PlayData"); + + migrationBuilder.DropColumn( + name: "Id", + table: "PlayData"); + + migrationBuilder.DropColumn( + name: "CreationDate", + table: "PlayData"); + + migrationBuilder.DropColumn( + name: "PlayId", + table: "PlayData"); + } +} diff --git a/util/PostgresMigrations/Migrations/DatabaseContextModelSnapshot.cs b/util/PostgresMigrations/Migrations/DatabaseContextModelSnapshot.cs index 64c8aec860..b87bb61e50 100644 --- a/util/PostgresMigrations/Migrations/DatabaseContextModelSnapshot.cs +++ b/util/PostgresMigrations/Migrations/DatabaseContextModelSnapshot.cs @@ -1662,28 +1662,6 @@ namespace Bit.PostgresMigrations.Migrations }); }); - modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SeededData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreationDate") - .HasColumnType("timestamp with time zone"); - - b.Property("Data") - .IsRequired() - .HasColumnType("text"); - - b.Property("RecipeName") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("SeededData"); - }); - modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Send", b => { b.Property("Id") diff --git a/util/SqliteMigrations/Migrations/20251105002117_2025-11-04_00_PlayData.cs b/util/SqliteMigrations/Migrations/20251105002117_2025-11-04_00_PlayData.cs deleted file mode 100644 index 51e977d6dd..0000000000 --- a/util/SqliteMigrations/Migrations/20251105002117_2025-11-04_00_PlayData.cs +++ /dev/null @@ -1,80 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Bit.SqliteMigrations.Migrations; - -/// -public partial class _20251104_00_PlayData : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "PlayData", - columns: table => new - { - Id = table.Column(type: "TEXT", nullable: false), - PlayId = table.Column(type: "TEXT", maxLength: 256, nullable: false), - UserId = table.Column(type: "TEXT", nullable: true), - OrganizationId = table.Column(type: "TEXT", nullable: true), - CreationDate = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_PlayData", x => x.Id); - table.CheckConstraint("CK_PlayData_UserOrOrganization", "([UserId] IS NOT NULL AND [OrganizationId] IS NULL) OR ([UserId] IS NULL AND [OrganizationId] IS NOT NULL)"); - table.ForeignKey( - name: "FK_PlayData_Organization_OrganizationId", - column: x => x.OrganizationId, - principalTable: "Organization", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_PlayData_User_UserId", - column: x => x.UserId, - principalTable: "User", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "SeededData", - columns: table => new - { - Id = table.Column(type: "TEXT", nullable: false), - RecipeName = table.Column(type: "TEXT", nullable: false), - Data = table.Column(type: "TEXT", nullable: false), - CreationDate = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_SeededData", x => x.Id); - }); - - migrationBuilder.CreateIndex( - name: "IX_PlayData_OrganizationId", - table: "PlayData", - column: "OrganizationId"); - - migrationBuilder.CreateIndex( - name: "IX_PlayData_PlayId", - table: "PlayData", - column: "PlayId"); - - migrationBuilder.CreateIndex( - name: "IX_PlayData_UserId", - table: "PlayData", - column: "UserId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "PlayData"); - - migrationBuilder.DropTable( - name: "SeededData"); - } -} diff --git a/util/SqliteMigrations/Migrations/20251105002117_2025-11-04_00_PlayData.Designer.cs b/util/SqliteMigrations/Migrations/20251117210127_PlayData.Designer.cs similarity index 98% rename from util/SqliteMigrations/Migrations/20251105002117_2025-11-04_00_PlayData.Designer.cs rename to util/SqliteMigrations/Migrations/20251117210127_PlayData.Designer.cs index dc1894c638..968849b9a3 100644 --- a/util/SqliteMigrations/Migrations/20251105002117_2025-11-04_00_PlayData.Designer.cs +++ b/util/SqliteMigrations/Migrations/20251117210127_PlayData.Designer.cs @@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Bit.SqliteMigrations.Migrations { [DbContext(typeof(DatabaseContext))] - [Migration("20251105002117_2025-11-04_00_PlayData")] - partial class _20251104_00_PlayData + [Migration("20251117210127_PlayData")] + partial class PlayData { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -1006,6 +1006,12 @@ namespace Bit.SqliteMigrations.Migrations b.Property("Id") .HasColumnType("TEXT"); + b.Property("ApplicationAtRiskCount") + .HasColumnType("INTEGER"); + + b.Property("ApplicationCount") + .HasColumnType("INTEGER"); + b.Property("ApplicationData") .HasColumnType("TEXT"); @@ -1016,9 +1022,39 @@ namespace Bit.SqliteMigrations.Migrations b.Property("CreationDate") .HasColumnType("TEXT"); + b.Property("CriticalApplicationAtRiskCount") + .HasColumnType("INTEGER"); + + b.Property("CriticalApplicationCount") + .HasColumnType("INTEGER"); + + b.Property("CriticalMemberAtRiskCount") + .HasColumnType("INTEGER"); + + b.Property("CriticalMemberCount") + .HasColumnType("INTEGER"); + + b.Property("CriticalPasswordAtRiskCount") + .HasColumnType("INTEGER"); + + b.Property("CriticalPasswordCount") + .HasColumnType("INTEGER"); + + b.Property("MemberAtRiskCount") + .HasColumnType("INTEGER"); + + b.Property("MemberCount") + .HasColumnType("INTEGER"); + b.Property("OrganizationId") .HasColumnType("TEXT"); + b.Property("PasswordAtRiskCount") + .HasColumnType("INTEGER"); + + b.Property("PasswordCount") + .HasColumnType("INTEGER"); + b.Property("ReportData") .IsRequired() .HasColumnType("TEXT"); @@ -1613,28 +1649,6 @@ namespace Bit.SqliteMigrations.Migrations }); }); - modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SeededData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("TEXT"); - - b.Property("CreationDate") - .HasColumnType("TEXT"); - - b.Property("Data") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("RecipeName") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("SeededData"); - }); - modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Send", b => { b.Property("Id") diff --git a/util/SqliteMigrations/Migrations/20251117210127_PlayData.cs b/util/SqliteMigrations/Migrations/20251117210127_PlayData.cs new file mode 100644 index 0000000000..9e5a4690b3 --- /dev/null +++ b/util/SqliteMigrations/Migrations/20251117210127_PlayData.cs @@ -0,0 +1,96 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Bit.SqliteMigrations.Migrations; + +/// +public partial class PlayData : Migration +{ + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Id", + table: "PlayData", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "CreationDate", + table: "PlayData", + type: "TEXT", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "PlayId", + table: "PlayData", + type: "TEXT", + maxLength: 256, + nullable: false, + defaultValue: ""); + + migrationBuilder.AddPrimaryKey( + name: "PK_PlayData", + table: "PlayData", + column: "Id"); + + migrationBuilder.CreateIndex( + name: "IX_PlayData_OrganizationId", + table: "PlayData", + column: "OrganizationId"); + + migrationBuilder.CreateIndex( + name: "IX_PlayData_PlayId", + table: "PlayData", + column: "PlayId"); + + migrationBuilder.CreateIndex( + name: "IX_PlayData_UserId", + table: "PlayData", + column: "UserId"); + + migrationBuilder.AddCheckConstraint( + name: "CK_PlayData_UserOrOrganization", + table: "PlayData", + sql: "([UserId] IS NOT NULL AND [OrganizationId] IS NULL) OR ([UserId] IS NULL AND [OrganizationId] IS NOT NULL)"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_PlayData", + table: "PlayData"); + + migrationBuilder.DropIndex( + name: "IX_PlayData_OrganizationId", + table: "PlayData"); + + migrationBuilder.DropIndex( + name: "IX_PlayData_PlayId", + table: "PlayData"); + + migrationBuilder.DropIndex( + name: "IX_PlayData_UserId", + table: "PlayData"); + + migrationBuilder.DropCheckConstraint( + name: "CK_PlayData_UserOrOrganization", + table: "PlayData"); + + migrationBuilder.DropColumn( + name: "Id", + table: "PlayData"); + + migrationBuilder.DropColumn( + name: "CreationDate", + table: "PlayData"); + + migrationBuilder.DropColumn( + name: "PlayId", + table: "PlayData"); + } +} diff --git a/util/SqliteMigrations/Migrations/DatabaseContextModelSnapshot.cs b/util/SqliteMigrations/Migrations/DatabaseContextModelSnapshot.cs index 21ff8f134a..58d1e2b15e 100644 --- a/util/SqliteMigrations/Migrations/DatabaseContextModelSnapshot.cs +++ b/util/SqliteMigrations/Migrations/DatabaseContextModelSnapshot.cs @@ -1646,28 +1646,6 @@ namespace Bit.SqliteMigrations.Migrations }); }); - modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SeededData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("TEXT"); - - b.Property("CreationDate") - .HasColumnType("TEXT"); - - b.Property("Data") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("RecipeName") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("SeededData"); - }); - modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Send", b => { b.Property("Id")