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

PM-20574 & PM-20575 Adding Risk Insight Report tables, repositories, and migrations (#5839)

* PM-20574 fixing namespaces on reporting work that got moved over from tools

* PM-20574 adding tables, stored procedures, and migration files

* PM-20574 adding dapper and ef repos and migrations

* PM-20574 changing table and repo names as requested

* PM-20574 updating sql scripts to new names

* PM-20574 updating sql scripts

* PM-20574 updating migration script for org delete by id

* PM-20574 adding mysql migration

* PM-20574 updating sql migration to fix database test

* PM-20574 fixing migration script

* PM-20574 fixing migration script

* PM-20574 fixing table scripts

* PM-20574 fixing table scripts

* PM-20574 fixing migration script formatting

* PM-20574 fixing syntax in migration script

* PM-20574 fixing file names and extensions

* PM-20574 fixing sql file

* PM-20574 fixing sql

* PM-20574 fixing directory for entities and removing scripts from other databases

* PM-20574 generating new migration scripts

* PM-20574 fixed reference to a stored proc

* PM-20574 adding index in scripts and missing table

* PM-20574 fixing merge conflicts

* PM-20574 set OUTPUT param for Id property in create and update proc

* PM-20574 add CreateDate to the update proc

* PM-20574 amend update proc for OrganizationApplication by adding createDate

* PM-20574 formatted sql and updated as per PR comments

* PM-20574 updated script to fix build error

* PM-20574 fixed inconsistency in db script

* PM-20574 removed revisionDate, update procedures and used views

* PM-20574 removed RevisionDate from designer files

* PM-20574 removed revisionDate column that was missed previously

* PM-20574 added revision date back into the mix

* PM-20574 updated database script to fix build error

* PM-20574 fixed a procedure issue

* PM-20574 fix dB build error

* PM-020574 fixed additional PR comments - files cleaned up

* PM-20574 updated procedure was inconsistent

* Update 2025-06-13-00_OrganizationReport.sql

---------

Co-authored-by: voommen-livefront <voommen@livefront.com>
This commit is contained in:
Graham Walker
2025-06-23 12:12:04 -05:00
committed by GitHub
parent d2410747d0
commit 173db0a2dd
66 changed files with 11103 additions and 33 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,93 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.SqliteMigrations.Migrations;
/// <inheritdoc />
public partial class _2025061300_OrganizationReportsql : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "OrganizationApplication",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
OrganizationId = table.Column<Guid>(type: "TEXT", nullable: false),
Applications = table.Column<string>(type: "TEXT", nullable: false),
CreationDate = table.Column<DateTime>(type: "TEXT", nullable: false),
RevisionDate = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_OrganizationApplication", x => x.Id);
table.ForeignKey(
name: "FK_OrganizationApplication_Organization_OrganizationId",
column: x => x.OrganizationId,
principalTable: "Organization",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "OrganizationReport",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
OrganizationId = table.Column<Guid>(type: "TEXT", nullable: false),
Date = table.Column<DateTime>(type: "TEXT", nullable: false),
ReportData = table.Column<string>(type: "TEXT", nullable: false),
CreationDate = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_OrganizationReport", x => x.Id);
table.ForeignKey(
name: "FK_OrganizationReport_Organization_OrganizationId",
column: x => x.OrganizationId,
principalTable: "Organization",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_OrganizationApplication_Id",
table: "OrganizationApplication",
column: "Id");
migrationBuilder.CreateIndex(
name: "IX_OrganizationApplication_OrganizationId",
table: "OrganizationApplication",
column: "OrganizationId");
migrationBuilder.CreateIndex(
name: "IX_OrganizationReport_Id",
table: "OrganizationReport",
column: "Id");
migrationBuilder.CreateIndex(
name: "IX_OrganizationReport_OrganizationId",
table: "OrganizationReport",
column: "OrganizationId");
migrationBuilder.CreateIndex(
name: "IX_OrganizationReport_OrganizationId_Date",
table: "OrganizationReport",
columns: ["OrganizationId", "Date"],
descending: [false, true]);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "OrganizationApplication");
migrationBuilder.DropTable(
name: "OrganizationReport");
}
}

View File

@ -956,6 +956,64 @@ namespace Bit.SqliteMigrations.Migrations
b.ToTable("ProviderPlan", (string)null);
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Dirt.Models.OrganizationApplication", b =>
{
b.Property<Guid>("Id")
.HasColumnType("TEXT");
b.Property<string>("Applications")
.IsRequired()
.HasColumnType("TEXT");
b.Property<DateTime>("CreationDate")
.HasColumnType("TEXT");
b.Property<Guid>("OrganizationId")
.HasColumnType("TEXT");
b.Property<DateTime>("RevisionDate")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("Id")
.HasAnnotation("SqlServer:Clustered", true);
b.HasIndex("OrganizationId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("OrganizationApplication", (string)null);
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Dirt.Models.OrganizationReport", b =>
{
b.Property<Guid>("Id")
.HasColumnType("TEXT");
b.Property<DateTime>("CreationDate")
.HasColumnType("TEXT");
b.Property<DateTime>("Date")
.HasColumnType("TEXT");
b.Property<Guid>("OrganizationId")
.HasColumnType("TEXT");
b.Property<string>("ReportData")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("Id")
.HasAnnotation("SqlServer:Clustered", true);
b.HasIndex("OrganizationId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("OrganizationReport", (string)null);
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Dirt.Models.PasswordHealthReportApplication", b =>
{
b.Property<Guid>("Id")
@ -2568,6 +2626,28 @@ namespace Bit.SqliteMigrations.Migrations
b.Navigation("Provider");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Dirt.Models.OrganizationApplication", 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.Dirt.Models.OrganizationReport", 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.Dirt.Models.PasswordHealthReportApplication", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.AdminConsole.Models.Organization", "Organization")