1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-24 20:58:49 -05:00

PM-20574 removed revisionDate, update procedures and used views

This commit is contained in:
voommen-livefront 2025-06-20 13:56:10 -05:00
parent 360ee89d4e
commit 22a89cc8da
15 changed files with 34 additions and 157 deletions

View File

@ -5,13 +5,12 @@ using Bit.Core.Utilities;
namespace Bit.Core.Dirt.Entities; namespace Bit.Core.Dirt.Entities;
public class OrganizationApplication : ITableObject<Guid>, IRevisable public class OrganizationApplication : ITableObject<Guid>
{ {
public Guid Id { get; set; } public Guid Id { get; set; }
public Guid OrganizationId { get; set; } public Guid OrganizationId { get; set; }
public string Applications { get; set; } = string.Empty; public string Applications { get; set; } = string.Empty;
public DateTime CreationDate { get; set; } = DateTime.UtcNow; public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime RevisionDate { get; set; } = DateTime.UtcNow;
public void SetNewId() public void SetNewId()
{ {

View File

@ -5,14 +5,13 @@ using Bit.Core.Utilities;
namespace Bit.Core.Dirt.Entities; namespace Bit.Core.Dirt.Entities;
public class OrganizationReport : ITableObject<Guid>, IRevisable public class OrganizationReport : ITableObject<Guid>
{ {
public Guid Id { get; set; } public Guid Id { get; set; }
public Guid OrganizationId { get; set; } public Guid OrganizationId { get; set; }
public DateTime Date { get; set; } public DateTime Date { get; set; }
public string ReportData { get; set; } = string.Empty; public string ReportData { get; set; } = string.Empty;
public DateTime CreationDate { get; set; } = DateTime.UtcNow; public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime RevisionDate { get; set; } = DateTime.UtcNow;
public void SetNewId() public void SetNewId()
{ {

View File

@ -2,8 +2,7 @@ CREATE PROCEDURE [dbo].[OrganizationApplication_Create]
@Id UNIQUEIDENTIFIER OUTPUT, @Id UNIQUEIDENTIFIER OUTPUT,
@OrganizationId UNIQUEIDENTIFIER, @OrganizationId UNIQUEIDENTIFIER,
@Applications NVARCHAR(MAX), @Applications NVARCHAR(MAX),
@CreationDate DATETIME2(7), @CreationDate DATETIME2(7)
@RevisionDate DATETIME2(7)
AS AS
SET NOCOUNT ON; SET NOCOUNT ON;
@ -12,14 +11,12 @@ AS
[Id], [Id],
[OrganizationId], [OrganizationId],
[Applications], [Applications],
[CreationDate], [CreationDate]
[RevisionDate]
) )
VALUES VALUES
( (
@Id, @Id,
@OrganizationId, @OrganizationId,
@Applications, @Applications,
@CreationDate, @CreationDate
@RevisionDate );
);

View File

@ -4,10 +4,6 @@ AS
SET NOCOUNT ON; SET NOCOUNT ON;
SELECT SELECT
[Id], *
[OrganizationId],
[Applications],
[CreationDate],
[RevisionDate]
FROM [dbo].[OrganizationApplicationView] FROM [dbo].[OrganizationApplicationView]
WHERE [Id] = @Id; WHERE [Id] = @Id;

View File

@ -4,10 +4,6 @@ AS
SET NOCOUNT ON; SET NOCOUNT ON;
SELECT SELECT
[Id], *
[OrganizationId],
[Applications],
[CreationDate],
[RevisionDate]
FROM [dbo].[OrganizationApplicationView] FROM [dbo].[OrganizationApplicationView]
WHERE [OrganizationId] = @OrganizationId; WHERE [OrganizationId] = @OrganizationId;

View File

@ -1,14 +0,0 @@
CREATE PROCEDURE [dbo].[OrganizationApplication_Update]
@Id UNIQUEIDENTIFIER OUTPUT,
@OrganizationId UNIQUEIDENTIFIER,
@Applications NVARCHAR(MAX),
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7)
AS
SET NOCOUNT ON;
UPDATE [dbo].[OrganizationApplication]
SET
[OrganizationId] = @OrganizationId,
[Applications] = @Applications,
[RevisionDate] = @RevisionDate
WHERE [Id] = @Id;

View File

@ -3,8 +3,7 @@ CREATE PROCEDURE [dbo].[OrganizationReport_Create]
@OrganizationId UNIQUEIDENTIFIER, @OrganizationId UNIQUEIDENTIFIER,
@Date DATETIME2(7), @Date DATETIME2(7),
@ReportData NVARCHAR(MAX), @ReportData NVARCHAR(MAX),
@CreationDate DATETIME2(7), @CreationDate DATETIME2(7)
@RevisionDate DATETIME2(7)
AS AS
SET NOCOUNT ON; SET NOCOUNT ON;
@ -13,14 +12,12 @@ AS
[OrganizationId], [OrganizationId],
[Date], [Date],
[ReportData], [ReportData],
[CreationDate], [CreationDate]
[RevisionDate]
) )
VALUES ( VALUES (
@Id, @Id,
@OrganizationId, @OrganizationId,
@Date, @Date,
@ReportData, @ReportData,
@CreationDate, @CreationDate
@RevisionDate
); );

View File

@ -4,11 +4,6 @@ AS
SET NOCOUNT ON; SET NOCOUNT ON;
SELECT SELECT
[Id], *
[OrganizationId], FROM [dbo].[OrganizationReportView]
[Date],
[ReportData],
[CreationDate],
[RevisionDate]
FROM [dbo].[OrganizationReport]
WHERE [Id] = @Id; WHERE [Id] = @Id;

View File

@ -4,11 +4,6 @@ AS
SET NOCOUNT ON; SET NOCOUNT ON;
SELECT SELECT
[Id], *
[OrganizationId], FROM [dbo].[OrganizationReportView]
[Date],
[ReportData],
[CreationDate],
[RevisionDate]
FROM [dbo].[OrganizationReport]
WHERE [OrganizationId] = @OrganizationId; WHERE [OrganizationId] = @OrganizationId;

View File

@ -1,16 +0,0 @@
CREATE PROCEDURE [dbo].[OrganizationReport_Update]
@Id UNIQUEIDENTIFIER OUTPUT,
@OrganizationId UNIQUEIDENTIFIER,
@Date DATETIME2(7),
@ReportData NVARCHAR(MAX),
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7)
AS
SET NOCOUNT ON;
UPDATE [dbo].[OrganizationReport]
SET [OrganizationId] = @OrganizationId,
[Date] = @Date,
[ReportData] = @ReportData,
[RevisionDate] = @RevisionDate
WHERE [Id] = @Id;

View File

@ -7,7 +7,6 @@ BEGIN
[Date] DATETIME2 (7) NOT NULL, [Date] DATETIME2 (7) NOT NULL,
[ReportData] NVARCHAR(MAX) NOT NULL, [ReportData] NVARCHAR(MAX) NOT NULL,
[CreationDate] DATETIME2 (7) NOT NULL, [CreationDate] DATETIME2 (7) NOT NULL,
[RevisionDate] DATETIME2 (7) NOT NULL,
CONSTRAINT [PK_OrganizationReport] PRIMARY KEY CLUSTERED ([Id] ASC), CONSTRAINT [PK_OrganizationReport] PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_OrganizationReport_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]) CONSTRAINT [FK_OrganizationReport_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id])
); );
@ -32,8 +31,7 @@ CREATE PROCEDURE [dbo].[OrganizationReport_Create]
@OrganizationId UNIQUEIDENTIFIER, @OrganizationId UNIQUEIDENTIFIER,
@Date DATETIME2(7), @Date DATETIME2(7),
@ReportData NVARCHAR(MAX), @ReportData NVARCHAR(MAX),
@CreationDate DATETIME2(7), @CreationDate DATETIME2(7)
@RevisionDate DATETIME2(7)
AS AS
SET NOCOUNT ON; SET NOCOUNT ON;
@ -42,16 +40,14 @@ AS
[OrganizationId], [OrganizationId],
[Date], [Date],
[ReportData], [ReportData],
[CreationDate], [CreationDate]
[RevisionDate]
) )
VALUES ( VALUES (
@Id, @Id,
@OrganizationId, @OrganizationId,
@Date, @Date,
@ReportData, @ReportData,
@CreationDate, @CreationDate
@RevisionDate
); );
GO GO
@ -71,13 +67,8 @@ AS
SET NOCOUNT ON; SET NOCOUNT ON;
SELECT SELECT
[Id], *
[OrganizationId], FROM [dbo].[OrganizationReportView]
[Date],
[ReportData],
[CreationDate],
[RevisionDate]
FROM [dbo].[OrganizationReport]
WHERE [Id] = @Id; WHERE [Id] = @Id;
GO GO
@ -88,31 +79,7 @@ AS
SET NOCOUNT ON; SET NOCOUNT ON;
SELECT SELECT
[Id], *
[OrganizationId], FROM [dbo].[OrganizationReportView]
[Date],
[ReportData],
[CreationDate],
[RevisionDate]
FROM [dbo].[OrganizationReport]
WHERE [OrganizationId] = @OrganizationId; WHERE [OrganizationId] = @OrganizationId;
GO GO
CREATE OR ALTER PROCEDURE [dbo].[OrganizationReport_Update]
@Id UNIQUEIDENTIFIER OUTPUT,
@OrganizationId UNIQUEIDENTIFIER,
@Date DATETIME2(7),
@ReportData NVARCHAR(MAX),
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7)
AS
SET NOCOUNT ON;
UPDATE [dbo].[OrganizationReport]
SET [OrganizationId] = @OrganizationId,
[Date] = @Date,
[ReportData] = @ReportData,
[RevisionDate] = @RevisionDate
WHERE [Id] = @Id;
GO

View File

@ -6,7 +6,6 @@ BEGIN
[OrganizationId] UNIQUEIDENTIFIER NOT NULL, [OrganizationId] UNIQUEIDENTIFIER NOT NULL,
[Applications] NVARCHAR(MAX) NOT NULL, [Applications] NVARCHAR(MAX) NOT NULL,
[CreationDate] DATETIME2 (7) NOT NULL, [CreationDate] DATETIME2 (7) NOT NULL,
[RevisionDate] DATETIME2 (7) NOT NULL,
CONSTRAINT [PK_OrganizationApplication] PRIMARY KEY CLUSTERED ([Id] ASC), CONSTRAINT [PK_OrganizationApplication] PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_OrganizationApplication_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]) CONSTRAINT [FK_OrganizationApplication_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id])
); );
@ -27,8 +26,7 @@ CREATE OR ALTER PROCEDURE [dbo].[OrganizationApplication_Create]
@Id UNIQUEIDENTIFIER OUTPUT, @Id UNIQUEIDENTIFIER OUTPUT,
@OrganizationId UNIQUEIDENTIFIER, @OrganizationId UNIQUEIDENTIFIER,
@Applications NVARCHAR(MAX), @Applications NVARCHAR(MAX),
@CreationDate DATETIME2(7), @CreationDate DATETIME2(7)
@RevisionDate DATETIME2(7)
AS AS
SET NOCOUNT ON; SET NOCOUNT ON;
@ -37,17 +35,15 @@ AS
[Id], [Id],
[OrganizationId], [OrganizationId],
[Applications], [Applications],
[CreationDate], [CreationDate]
[RevisionDate]
) )
VALUES VALUES
( (
@Id, @Id,
@OrganizationId, @OrganizationId,
@Applications, @Applications,
@CreationDate, @CreationDate
@RevisionDate );
);
GO GO
@ -69,11 +65,7 @@ AS
SET NOCOUNT ON; SET NOCOUNT ON;
SELECT SELECT
[Id], *
[OrganizationId],
[Applications],
[CreationDate],
[RevisionDate]
FROM [dbo].[OrganizationApplicationView] FROM [dbo].[OrganizationApplicationView]
WHERE [Id] = @Id; WHERE [Id] = @Id;
@ -85,29 +77,9 @@ AS
SET NOCOUNT ON; SET NOCOUNT ON;
SELECT SELECT
[Id], *
[OrganizationId],
[Applications],
[CreationDate],
[RevisionDate]
FROM [dbo].[OrganizationApplicationView] FROM [dbo].[OrganizationApplicationView]
WHERE [OrganizationId] = @OrganizationId; WHERE [OrganizationId] = @OrganizationId;
GO GO
CREATE OR ALTER PROCEDURE [dbo].[OrganizationApplication_Update]
@Id UNIQUEIDENTIFIER OUTPUT,
@OrganizationId UNIQUEIDENTIFIER,
@Applications NVARCHAR(MAX),
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7)
AS
SET NOCOUNT ON;
UPDATE [dbo].[OrganizationApplication]
SET
[OrganizationId] = @OrganizationId,
[Applications] = @Applications,
[RevisionDate] = @RevisionDate
WHERE [Id] = @Id;
GO

View File

@ -18,8 +18,7 @@ public partial class _2025061300_OrganizationReportsql : Migration
OrganizationId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), OrganizationId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Applications = table.Column<string>(type: "longtext", nullable: false) Applications = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
CreationDate = table.Column<DateTime>(type: "datetime(6)", nullable: false), CreationDate = table.Column<DateTime>(type: "datetime(6)", nullable: false)
RevisionDate = table.Column<DateTime>(type: "datetime(6)", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
@ -42,8 +41,7 @@ public partial class _2025061300_OrganizationReportsql : Migration
Date = table.Column<DateTime>(type: "datetime(6)", nullable: false), Date = table.Column<DateTime>(type: "datetime(6)", nullable: false),
ReportData = table.Column<string>(type: "longtext", nullable: false) ReportData = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
CreationDate = table.Column<DateTime>(type: "datetime(6)", nullable: false), CreationDate = table.Column<DateTime>(type: "datetime(6)", nullable: false)
RevisionDate = table.Column<DateTime>(type: "datetime(6)", nullable: false)
}, },
constraints: table => constraints: table =>
{ {

View File

@ -17,8 +17,7 @@ public partial class _2025061300_OrganizationReportsql : Migration
Id = table.Column<Guid>(type: "uuid", nullable: false), Id = table.Column<Guid>(type: "uuid", nullable: false),
OrganizationId = table.Column<Guid>(type: "uuid", nullable: false), OrganizationId = table.Column<Guid>(type: "uuid", nullable: false),
Applications = table.Column<string>(type: "text", nullable: false), Applications = table.Column<string>(type: "text", nullable: false),
CreationDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), CreationDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
RevisionDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
@ -39,8 +38,7 @@ public partial class _2025061300_OrganizationReportsql : Migration
OrganizationId = table.Column<Guid>(type: "uuid", nullable: false), OrganizationId = table.Column<Guid>(type: "uuid", nullable: false),
Date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), Date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
ReportData = table.Column<string>(type: "text", nullable: false), ReportData = table.Column<string>(type: "text", nullable: false),
CreationDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), CreationDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
RevisionDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
}, },
constraints: table => constraints: table =>
{ {

View File

@ -17,8 +17,7 @@ public partial class _2025061300_OrganizationReportsql : Migration
Id = table.Column<Guid>(type: "TEXT", nullable: false), Id = table.Column<Guid>(type: "TEXT", nullable: false),
OrganizationId = table.Column<Guid>(type: "TEXT", nullable: false), OrganizationId = table.Column<Guid>(type: "TEXT", nullable: false),
Applications = table.Column<string>(type: "TEXT", nullable: false), Applications = table.Column<string>(type: "TEXT", nullable: false),
CreationDate = table.Column<DateTime>(type: "TEXT", nullable: false), CreationDate = table.Column<DateTime>(type: "TEXT", nullable: false)
RevisionDate = table.Column<DateTime>(type: "TEXT", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
@ -39,8 +38,7 @@ public partial class _2025061300_OrganizationReportsql : Migration
OrganizationId = table.Column<Guid>(type: "TEXT", nullable: false), OrganizationId = table.Column<Guid>(type: "TEXT", nullable: false),
Date = table.Column<DateTime>(type: "TEXT", nullable: false), Date = table.Column<DateTime>(type: "TEXT", nullable: false),
ReportData = table.Column<string>(type: "TEXT", nullable: false), ReportData = table.Column<string>(type: "TEXT", nullable: false),
CreationDate = table.Column<DateTime>(type: "TEXT", nullable: false), CreationDate = table.Column<DateTime>(type: "TEXT", nullable: false)
RevisionDate = table.Column<DateTime>(type: "TEXT", nullable: false)
}, },
constraints: table => constraints: table =>
{ {