mirror of
https://github.com/bitwarden/server.git
synced 2024-11-21 12:05:42 +01:00
PM-13236 PasswordHealthReportApplication DB Tables (#4958)
* PM-13236 PasswordHealthReportApplications db * PM-13236 incorporated pr comments * PM-13236 fixed error in SQL script * PM-13236 resolve quality scan errors SQL71006, SQL7101, SQL70001 * PM-13236 fixed warnings on procedures * PM-13236 added efMigrations * PM-13236 renamed files to PasswordHealthReportApplication (singular) * PM-13236 changed file name to more appropriate naming * PM-13236 changed the file name singular * PM-13236 removed the entity file * PM-13236 Moved PasswordHealthReportApplication entity to src/core/tools/entities
This commit is contained in:
parent
4b76008245
commit
cb7eecc96d
16
src/Core/Tools/Entities/PasswordHealthReportApplication.cs
Normal file
16
src/Core/Tools/Entities/PasswordHealthReportApplication.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using Bit.Core.Entities;
|
||||||
|
using Bit.Core.Utilities;
|
||||||
|
|
||||||
|
public class PasswordHealthReportApplication : ITableObject<Guid>, IRevisable
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public Guid OrganizationId { get; set; }
|
||||||
|
public string Uri { get; set; }
|
||||||
|
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
|
||||||
|
public DateTime RevisionDate { get; set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
|
public void SetNewId()
|
||||||
|
{
|
||||||
|
Id = CoreHelpers.GenerateComb();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
CREATE PROCEDURE dbo.PasswordHealthReportApplication_Create
|
||||||
|
@Id UNIQUEIDENTIFIER OUTPUT,
|
||||||
|
@OrganizationId UNIQUEIDENTIFIER,
|
||||||
|
@Uri nvarchar(max),
|
||||||
|
@CreationDate DATETIME2(7),
|
||||||
|
@RevisionDate DATETIME2(7)
|
||||||
|
AS
|
||||||
|
SET NOCOUNT ON;
|
||||||
|
INSERT INTO dbo.PasswordHealthReportApplication ( Id, OrganizationId, Uri, CreationDate, RevisionDate )
|
||||||
|
VALUES ( @Id, @OrganizationId, @Uri, @CreationDate, @RevisionDate )
|
@ -0,0 +1,10 @@
|
|||||||
|
CREATE PROCEDURE dbo.PasswordHealthReportApplication_DeleteById
|
||||||
|
@Id UNIQUEIDENTIFIER
|
||||||
|
AS
|
||||||
|
SET NOCOUNT ON;
|
||||||
|
|
||||||
|
IF @Id IS NULL
|
||||||
|
THROW 50000, 'Id cannot be null', 1;
|
||||||
|
|
||||||
|
DELETE FROM [dbo].[PasswordHealthReportApplication]
|
||||||
|
WHERE [Id] = @Id
|
@ -0,0 +1,16 @@
|
|||||||
|
CREATE PROCEDURE dbo.PasswordHealthReportApplication_ReadById
|
||||||
|
@Id UNIQUEIDENTIFIER
|
||||||
|
AS
|
||||||
|
SET NOCOUNT ON;
|
||||||
|
|
||||||
|
IF @Id IS NULL
|
||||||
|
THROW 50000, 'Id cannot be null', 1;
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
Id,
|
||||||
|
OrganizationId,
|
||||||
|
Uri,
|
||||||
|
CreationDate,
|
||||||
|
RevisionDate
|
||||||
|
FROM [dbo].[PasswordHealthReportApplicationView]
|
||||||
|
WHERE Id = @Id;
|
@ -0,0 +1,16 @@
|
|||||||
|
CREATE PROCEDURE dbo.PasswordHealthReportApplication_ReadByOrganizationId
|
||||||
|
@OrganizationId UNIQUEIDENTIFIER
|
||||||
|
AS
|
||||||
|
SET NOCOUNT ON;
|
||||||
|
|
||||||
|
IF @OrganizationId IS NULL
|
||||||
|
THROW 50000, 'OrganizationId cannot be null', 1;
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
Id,
|
||||||
|
OrganizationId,
|
||||||
|
Uri,
|
||||||
|
CreationDate,
|
||||||
|
RevisionDate
|
||||||
|
FROM [dbo].[PasswordHealthReportApplicationView]
|
||||||
|
WHERE OrganizationId = @OrganizationId;
|
@ -0,0 +1,13 @@
|
|||||||
|
CREATE PROC dbo.PasswordHealthReportApplication_Update
|
||||||
|
@Id UNIQUEIDENTIFIER OUTPUT,
|
||||||
|
@OrganizationId UNIQUEIDENTIFIER,
|
||||||
|
@Uri nvarchar(max),
|
||||||
|
@CreationDate DATETIME2(7),
|
||||||
|
@RevisionDate DATETIME2(7)
|
||||||
|
AS
|
||||||
|
SET NOCOUNT ON;
|
||||||
|
UPDATE dbo.PasswordHealthReportApplication
|
||||||
|
SET OrganizationId = @OrganizationId,
|
||||||
|
Uri = @Uri,
|
||||||
|
RevisionDate = @RevisionDate
|
||||||
|
WHERE Id = @Id
|
15
src/Sql/dbo/Tables/PasswordHealthReportApplication.sql
Normal file
15
src/Sql/dbo/Tables/PasswordHealthReportApplication.sql
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
CREATE TABLE [dbo].[PasswordHealthReportApplication]
|
||||||
|
(
|
||||||
|
Id UNIQUEIDENTIFIER NOT NULL,
|
||||||
|
OrganizationId UNIQUEIDENTIFIER NOT NULL,
|
||||||
|
Uri nvarchar(max),
|
||||||
|
CreationDate DATETIME2(7) NOT NULL,
|
||||||
|
RevisionDate DATETIME2(7) NOT NULL,
|
||||||
|
CONSTRAINT [PK_PasswordHealthReportApplication] PRIMARY KEY CLUSTERED ([Id] ASC),
|
||||||
|
CONSTRAINT [FK_PasswordHealthReportApplication_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]),
|
||||||
|
);
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE NONCLUSTERED INDEX [IX_PasswordHealthReportApplication_OrganizationId]
|
||||||
|
ON [dbo].[PasswordHealthReportApplication] (OrganizationId);
|
||||||
|
GO
|
@ -0,0 +1,2 @@
|
|||||||
|
CREATE VIEW [dbo].[PasswordHealthReportApplicationView] AS
|
||||||
|
SELECT * FROM [dbo].[PasswordHealthReportApplication]
|
@ -0,0 +1,103 @@
|
|||||||
|
|
||||||
|
IF OBJECT_ID('dbo.PasswordHealthReportApplication') IS NULL
|
||||||
|
BEGIN
|
||||||
|
CREATE TABLE [dbo].[PasswordHealthReportApplication]
|
||||||
|
(
|
||||||
|
Id UNIQUEIDENTIFIER NOT NULL,
|
||||||
|
OrganizationId UNIQUEIDENTIFIER NOT NULL,
|
||||||
|
Uri nvarchar(max),
|
||||||
|
CreationDate DATETIME2(7) NOT NULL,
|
||||||
|
RevisionDate DATETIME2(7) NOT NULL,
|
||||||
|
CONSTRAINT [PK_PasswordHealthReportApplication] PRIMARY KEY CLUSTERED ([Id] ASC),
|
||||||
|
CONSTRAINT [FK_PasswordHealthReportApplication_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]),
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE NONCLUSTERED INDEX [IX_PasswordHealthReportApplication_OrganizationId]
|
||||||
|
ON [dbo].[PasswordHealthReportApplication] (OrganizationId);
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
IF OBJECT_ID('dbo.PasswordHealthReportApplicationView') IS NOT NULL
|
||||||
|
BEGIN
|
||||||
|
DROP VIEW [dbo].[PasswordHealthReportApplicationView]
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE VIEW [dbo].[PasswordHealthReportApplicationView] AS
|
||||||
|
SELECT * FROM [dbo].[PasswordHealthReportApplication]
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE OR ALTER PROC dbo.PasswordHealthReportApplication_Create
|
||||||
|
@Id UNIQUEIDENTIFIER OUTPUT,
|
||||||
|
@OrganizationId UNIQUEIDENTIFIER,
|
||||||
|
@Uri nvarchar(max),
|
||||||
|
@CreationDate DATETIME2(7),
|
||||||
|
@RevisionDate DATETIME2(7)
|
||||||
|
AS
|
||||||
|
SET NOCOUNT ON;
|
||||||
|
INSERT INTO dbo.PasswordHealthReportApplication ( Id, OrganizationId, Uri, CreationDate, RevisionDate )
|
||||||
|
VALUES ( @Id, @OrganizationId, @Uri, @CreationDate, @RevisionDate )
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE OR ALTER PROC dbo.PasswordHealthReportApplication_ReadByOrganizationId
|
||||||
|
@OrganizationId UNIQUEIDENTIFIER
|
||||||
|
AS
|
||||||
|
SET NOCOUNT ON;
|
||||||
|
|
||||||
|
IF @OrganizationId IS NULL
|
||||||
|
THROW 50000, 'OrganizationId cannot be null', 1;
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
Id,
|
||||||
|
OrganizationId,
|
||||||
|
Uri,
|
||||||
|
CreationDate,
|
||||||
|
RevisionDate
|
||||||
|
FROM [dbo].[PasswordHealthReportApplicationView]
|
||||||
|
WHERE OrganizationId = @OrganizationId;
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE OR ALTER PROC dbo.PasswordHealthReportApplication_ReadById
|
||||||
|
@Id UNIQUEIDENTIFIER
|
||||||
|
AS
|
||||||
|
SET NOCOUNT ON;
|
||||||
|
|
||||||
|
IF @Id IS NULL
|
||||||
|
THROW 50000, 'Id cannot be null', 1;
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
Id,
|
||||||
|
OrganizationId,
|
||||||
|
Uri,
|
||||||
|
CreationDate,
|
||||||
|
RevisionDate
|
||||||
|
FROM [dbo].[PasswordHealthReportApplicationView]
|
||||||
|
WHERE Id = @Id;
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE OR ALTER PROC dbo.PasswordHealthReportApplication_Update
|
||||||
|
@Id UNIQUEIDENTIFIER OUTPUT,
|
||||||
|
@OrganizationId UNIQUEIDENTIFIER,
|
||||||
|
@Uri nvarchar(max),
|
||||||
|
@CreationDate DATETIME2(7),
|
||||||
|
@RevisionDate DATETIME2(7)
|
||||||
|
AS
|
||||||
|
SET NOCOUNT ON;
|
||||||
|
UPDATE dbo.PasswordHealthReportApplication
|
||||||
|
SET OrganizationId = @OrganizationId,
|
||||||
|
Uri = @Uri,
|
||||||
|
RevisionDate = @RevisionDate
|
||||||
|
WHERE Id = @Id
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE OR ALTER PROC dbo.PasswordHealthReportApplication_DeleteById
|
||||||
|
@Id UNIQUEIDENTIFIER
|
||||||
|
AS
|
||||||
|
SET NOCOUNT ON;
|
||||||
|
|
||||||
|
IF @Id IS NULL
|
||||||
|
THROW 50000, 'Id cannot be null', 1;
|
||||||
|
|
||||||
|
DELETE FROM [dbo].[PasswordHealthReportApplication]
|
||||||
|
WHERE [Id] = @Id
|
||||||
|
GO
|
2845
util/MySqlMigrations/Migrations/20241031154652_PasswordHealthReportApplication.Designer.cs
generated
Normal file
2845
util/MySqlMigrations/Migrations/20241031154652_PasswordHealthReportApplication.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,47 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Bit.MySqlMigrations.Migrations;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class PasswordHealthReportApplication : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "PasswordHealthReportApplication",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||||
|
OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
Uri = table.Column<string>(type: "longtext", nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
CreationDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||||
|
RevisionDate = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_PasswordHealthReportApplication", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PasswordHealthReportApplication_Organization_OrganizationId",
|
||||||
|
column: x => x.OrganizationId,
|
||||||
|
principalTable: "Organization",
|
||||||
|
principalColumn: "Id");
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PasswordHealthReportApplication_OrganizationId",
|
||||||
|
table: "PasswordHealthReportApplication",
|
||||||
|
column: "OrganizationId");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(name: "PasswordHealthReportApplication");
|
||||||
|
}
|
||||||
|
}
|
2851
util/PostgresMigrations/Migrations/20241031154656_PasswordHealthReportApplication.Designer.cs
generated
Normal file
2851
util/PostgresMigrations/Migrations/20241031154656_PasswordHealthReportApplication.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,43 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Bit.PostgresMigrations.Migrations;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class PasswordHealthReportApplication : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "PasswordHealthReportApplication",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
OrganizationId = table.Column<Guid>(type: "uuid", nullable: true),
|
||||||
|
Uri = table.Column<string>(type: "text", nullable: true),
|
||||||
|
CreationDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||||
|
RevisionDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_PasswordHealthReportApplication", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PasswordHealthReportApplication_Organization_OrganizationId",
|
||||||
|
column: x => x.OrganizationId,
|
||||||
|
principalTable: "Organization",
|
||||||
|
principalColumn: "Id");
|
||||||
|
});
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PasswordHealthReportApplication_OrganizationId",
|
||||||
|
table: "PasswordHealthReportApplication",
|
||||||
|
column: "OrganizationId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(name: "PasswordHealthReportApplication");
|
||||||
|
}
|
||||||
|
}
|
2834
util/SqliteMigrations/Migrations/20241031154700_PasswordHealthReportApplication.Designer.cs
generated
Normal file
2834
util/SqliteMigrations/Migrations/20241031154700_PasswordHealthReportApplication.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,43 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Bit.SqliteMigrations.Migrations;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class PasswordHealthReportApplication : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "PasswordHealthReportApplication",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||||
|
OrganizationId = table.Column<Guid>(type: "TEXT", nullable: true),
|
||||||
|
Uri = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
CreationDate = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||||
|
RevisionDate = table.Column<DateTime>(type: "TEXT", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_PasswordHealthReportApplication", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PasswordHealthReportApplication_Organization_OrganizationId",
|
||||||
|
column: x => x.OrganizationId,
|
||||||
|
principalTable: "Organization",
|
||||||
|
principalColumn: "Id");
|
||||||
|
});
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PasswordHealthReportApplication_OrganizationId",
|
||||||
|
table: "PasswordHealthReportApplication",
|
||||||
|
column: "OrganizationId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(name: "PasswordHealthReportApplication");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user