mirror of
https://github.com/bitwarden/server
synced 2025-12-06 00:03:34 +00:00
* PM-23754 initial commit * pm-23754 fixing controller tests * pm-23754 adding commands and queries * pm-23754 adding endpoints, command/queries, repositories, and sql migrations * pm-23754 add new sql scripts * PM-23754 adding sql scripts * pm-23754 * PM-23754 fixing migration script * PM-23754 fixing migration script again * PM-23754 fixing migration script validation * PM-23754 fixing db validation script issue * PM-23754 fixing endpoint and db validation * PM-23754 fixing unit tests * PM-23754 fixing implementation based on comments and tests * PM-23754 updating logging statements * PM-23754 making changes based on PR comments. * updating migration scripts * removing old migration files * update code based testing for whole data object for OrganizationReport and add a stored procedure. * updating services, unit tests, repository tests * fixing unit tests * fixing migration script * fixing migration script again * fixing migration script * another fix * fixing sql file, updating controller to account for different orgIds in the url and body. * updating error message in controllers without a body * making a change to the command * Refactor ReportsController by removing organization reports The IDropOrganizationReportCommand is no longer needed * will code based on PR comments. * fixing unit test * fixing migration script based on last changes. * adding another check in endpoint and adding unit tests * fixing route parameter. * PM-23754 updating data fields to return just the column * PM-23754 fixing repository method signatures * PM-23754 making change to orgId parameter through out code to align with api naming --------- Co-authored-by: Tom <144813356+ttalty@users.noreply.github.com>
97 lines
2.3 KiB
Transact-SQL
97 lines
2.3 KiB
Transact-SQL
IF EXISTS (
|
|
SELECT * FROM sys.indexes WHERE name = 'IX_OrganizationReport_OrganizationId_Date'
|
|
AND object_id = OBJECT_ID('dbo.OrganizationReport')
|
|
)
|
|
BEGIN
|
|
DROP INDEX [IX_OrganizationReport_OrganizationId_Date] ON [dbo].[OrganizationReport];
|
|
END
|
|
GO
|
|
|
|
IF COL_LENGTH('[dbo].[OrganizationReport]', 'Date') IS NOT NULL
|
|
BEGIN
|
|
ALTER TABLE [dbo].[OrganizationReport]
|
|
DROP COLUMN [Date];
|
|
END
|
|
GO
|
|
|
|
IF OBJECT_ID('dbo.OrganizationReport') IS NOT NULL
|
|
BEGIN
|
|
ALTER TABLE [dbo].[OrganizationReport]
|
|
ADD [SummaryData] NVARCHAR(MAX) NULL,
|
|
[ApplicationData] NVARCHAR(MAX) NULL,
|
|
[RevisionDate] DATETIME2 (7) NULL;
|
|
END
|
|
GO
|
|
|
|
IF NOT EXISTS (
|
|
SELECT * FROM sys.indexes WHERE name = 'IX_OrganizationReport_OrganizationId_RevisionDate'
|
|
AND object_id = OBJECT_ID('dbo.OrganizationReport')
|
|
)
|
|
BEGIN
|
|
CREATE NONCLUSTERED INDEX [IX_OrganizationReport_OrganizationId_RevisionDate]
|
|
ON [dbo].[OrganizationReport]([OrganizationId] ASC, [RevisionDate] DESC);
|
|
END
|
|
GO
|
|
|
|
IF OBJECT_ID('dbo.OrganizationReportView') IS NOT NULL
|
|
BEGIN
|
|
DROP VIEW [dbo].[OrganizationReportView];
|
|
END
|
|
GO
|
|
|
|
IF OBJECT_ID('dbo.OrganizationReportView') IS NULL
|
|
BEGIN
|
|
EXEC('CREATE VIEW [dbo].[OrganizationReportView]
|
|
AS
|
|
SELECT
|
|
*
|
|
FROM
|
|
[dbo].[OrganizationReport]');
|
|
END
|
|
GO
|
|
|
|
IF OBJECT_ID('dbo.OrganizationReport_Create') IS NOT NULL
|
|
BEGIN
|
|
DROP PROCEDURE [dbo].[OrganizationReport_Create];
|
|
END
|
|
GO
|
|
|
|
IF OBJECT_ID('dbo.OrganizationReport_Create') IS NULL
|
|
BEGIN
|
|
EXEC('CREATE PROCEDURE [dbo].[OrganizationReport_Create]
|
|
@Id UNIQUEIDENTIFIER OUTPUT,
|
|
@OrganizationId UNIQUEIDENTIFIER,
|
|
@ReportData NVARCHAR(MAX),
|
|
@CreationDate DATETIME2(7),
|
|
@ContentEncryptionKey VARCHAR(MAX),
|
|
@SummaryData NVARCHAR(MAX),
|
|
@ApplicationData NVARCHAR(MAX),
|
|
@RevisionDate DATETIME2(7)
|
|
AS
|
|
BEGIN
|
|
SET NOCOUNT ON;
|
|
|
|
INSERT INTO [dbo].[OrganizationReport](
|
|
[Id],
|
|
[OrganizationId],
|
|
[ReportData],
|
|
[CreationDate],
|
|
[ContentEncryptionKey],
|
|
[SummaryData],
|
|
[ApplicationData],
|
|
[RevisionDate]
|
|
)
|
|
VALUES (
|
|
@Id,
|
|
@OrganizationId,
|
|
@ReportData,
|
|
@CreationDate,
|
|
@ContentEncryptionKey,
|
|
@SummaryData,
|
|
@ApplicationData,
|
|
@RevisionDate
|
|
);
|
|
END');
|
|
END
|
|
GO
|