sync
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
USE [DocumedisUsageLogs]
|
||||
GO
|
||||
|
||||
/*
|
||||
MDDOC-878
|
||||
|
||||
Purge of the table DocumedisUsageLogs.dbo.Compendium2020UsageLogs
|
||||
|
||||
Records that are more than 7 months old will be purged.
|
||||
|
||||
Deletion is made in batches to avoid locking.
|
||||
*/
|
||||
CREATE PROCEDURE [purge_Compendium2020UsageLogs]
|
||||
AS
|
||||
BEGIN
|
||||
DECLARE @cutoff DATE = DATEADD(MONTH, -7, CURRENT_TIMESTAMP);
|
||||
DECLARE @batch INT = 5000;
|
||||
DECLARE @row_count INT = 1;
|
||||
|
||||
WHILE @row_count > 0
|
||||
BEGIN
|
||||
DELETE TOP(@batch) s
|
||||
FROM [dbo].[Compendium2020UsageLogs] s
|
||||
WHERE [s].[LogDateTime] > @cutoff;
|
||||
|
||||
SET @row_count = @@rowcount;
|
||||
END
|
||||
END
|
||||
@@ -0,0 +1,28 @@
|
||||
USE [DocumedisUsageLogs]
|
||||
GO
|
||||
|
||||
/*
|
||||
MDDOC-878
|
||||
|
||||
Purge of the table DocumedisUsageLogs.dbo.Documedis2020UsageLogs
|
||||
|
||||
Records that are more than 7 months old will be purged.
|
||||
|
||||
Deletion is made in batches to avoid locking.
|
||||
*/
|
||||
CREATE PROCEDURE [purge_Documedis2020UsageLogs]
|
||||
AS
|
||||
BEGIN
|
||||
DECLARE @cutoff DATE = DATEADD(MONTH, -7, CURRENT_TIMESTAMP);
|
||||
DECLARE @batch INT = 5000;
|
||||
DECLARE @row_count INT = 1;
|
||||
|
||||
WHILE @row_count > 0
|
||||
BEGIN
|
||||
DELETE TOP(@batch) s
|
||||
FROM [dbo].[Documedis2020UsageLogs] s
|
||||
WHERE [s].[LogDateTime] > @cutoff;
|
||||
|
||||
SET @row_count = @@rowcount;
|
||||
END
|
||||
END
|
||||
@@ -0,0 +1,28 @@
|
||||
USE [DocumedisUsageLogs]
|
||||
GO
|
||||
|
||||
/*
|
||||
MDDOC-878
|
||||
|
||||
Purge of the table DocumedisUsageLogs.dbo.Pharmavista2020UsageLogs
|
||||
|
||||
Records that are more than 7 months old will be purged.
|
||||
|
||||
Deletion is made in batches to avoid locking.
|
||||
*/
|
||||
CREATE PROCEDURE [purge_Pharmavista2020UsageLogs]
|
||||
AS
|
||||
BEGIN
|
||||
DECLARE @cutoff DATE = DATEADD(MONTH, -7, CURRENT_TIMESTAMP);
|
||||
DECLARE @batch INT = 5000;
|
||||
DECLARE @row_count INT = 1;
|
||||
|
||||
WHILE @row_count > 0
|
||||
BEGIN
|
||||
DELETE TOP(@batch) s
|
||||
FROM [dbo].[Pharmavista2020UsageLogs] s
|
||||
WHERE [s].[LogDateTime] > @cutoff;
|
||||
|
||||
SET @row_count = @@rowcount;
|
||||
END
|
||||
END
|
||||
@@ -0,0 +1,26 @@
|
||||
USE [DocumedisUsageLogs]
|
||||
GO
|
||||
|
||||
/*
|
||||
MDDOC-878
|
||||
|
||||
Purge of the table DocumedisUsageLogs.dbo.Api2020UsageLogs
|
||||
|
||||
Records that are more than 7 months old will be purged.
|
||||
|
||||
Deletion is made in batches to avoid locking.
|
||||
*/
|
||||
CREATE PROCEDURE [purge_Api2020UsageLogs]
|
||||
AS
|
||||
BEGIN
|
||||
DECLARE @cutoff DATE = DATEADD(MONTH, -7, CURRENT_TIMESTAMP);
|
||||
DECLARE @batch INT = 5000;
|
||||
DECLARE @row_count INT = 1;
|
||||
|
||||
WHILE @row_count > 0
|
||||
BEGIN
|
||||
DELETE TOP(@batch) s
|
||||
FROM [dbo].[Api2020UsageLogs] s
|
||||
WHERE [s].[LogDateTime] > @cutoff;
|
||||
END
|
||||
END
|
||||
@@ -0,0 +1,82 @@
|
||||
USE [DocumedisLogs]
|
||||
GO
|
||||
|
||||
/*
|
||||
MDDOC-878
|
||||
|
||||
Purge of the table documedisLogs.dbo.Documedis_VaccinationCheck_LogData
|
||||
|
||||
Only records that are more than 7 months old and present as archived in [archivedRowsJournal]
|
||||
will be purged.
|
||||
All satellite tables are purged in order.
|
||||
|
||||
Deletion is made in batches to avoid locking.
|
||||
*/
|
||||
CREATE PROCEDURE [purge_Documedis_VaccinationCheck_LogData] AS
|
||||
BEGIN
|
||||
DECLARE @cutoff DATE = DATEADD(MONTH, -7, CURRENT_TIMESTAMP);
|
||||
DECLARE @batch INT = 5000;
|
||||
DECLARE @row_count INT = 1;
|
||||
DECLARE @tbl_to_del TABLE (DocumedisClinicalDecisionSupportLogData_PK BIGINT NOT NULL );
|
||||
|
||||
WHILE @row_count > 0
|
||||
BEGIN
|
||||
TRUNCATE TABLE @tbl_to_del;
|
||||
|
||||
-- region populate filter table
|
||||
INSERT INTO @tbl_to_del([DocumedisClinicalDecisionSupportLogData_PK])
|
||||
SELECT TOP (@batch)
|
||||
[s].[DocumedisClinicalDecisionSupportLogData_PK]
|
||||
FROM [dbo].[Documedis_ClinicalDecisionSupport_LogData] [s]
|
||||
WHERE [s].[LogDateTime] > @cutoff
|
||||
AND EXISTS(
|
||||
SELECT 1
|
||||
FROM [archivedRowsJournal] [a]
|
||||
WHERE [a].[tableName] = 'Documedis_ClinicalDecisionSupport_LogData'
|
||||
AND [a].[tableRowId] = [s].[DocumedisClinicalDecisionSupportLogData_PK]
|
||||
);
|
||||
|
||||
SELECT @row_count = COUNT(1)
|
||||
FROM @tbl_to_del;
|
||||
-- endregion
|
||||
|
||||
-- region logcheck products
|
||||
DELETE [lcp]
|
||||
FROM @tbl_to_del [d]
|
||||
INNER JOIN [Documedis_ClinicalDecisionSupport_LogCheck] [lc] ON [lc].[DocumedisClinicalDecisionSupportLogData_FK] = [d].[DocumedisClinicalDecisionSupportLogData_PK]
|
||||
INNER JOIN [Documedis_ClinicalDecisionSupport_LogCheckProduct] [lcp] ON [lc].[DocumedisClinicalDecisionSupportLogCheck_PK] = [lcp].[DocumedisClinicalDecisionSupportLogCheck_FK];
|
||||
-- endregion
|
||||
|
||||
-- region logcheck interactions
|
||||
DELETE [lci]
|
||||
FROM @tbl_to_del [d]
|
||||
INNER JOIN [Documedis_ClinicalDecisionSupport_LogCheck] [lc] ON [lc].[DocumedisClinicalDecisionSupportLogData_FK] = [d].[DocumedisClinicalDecisionSupportLogData_PK]
|
||||
INNER JOIN [Documedis_ClinicalDecisionSupport_LogCheckInteraction] [lci] ON [lc].[DocumedisClinicalDecisionSupportLogCheck_PK] = [lci].[DocumedisClinicalDecisionSupportLogCheck_FK];
|
||||
-- endregion
|
||||
|
||||
-- region logcheck
|
||||
DELETE [lc]
|
||||
FROM @tbl_to_del [d]
|
||||
INNER JOIN [Documedis_ClinicalDecisionSupport_LogCheck] [lc] ON [lc].[DocumedisClinicalDecisionSupportLogData_FK] = [d].[DocumedisClinicalDecisionSupportLogData_PK];
|
||||
-- endregion
|
||||
|
||||
-- region patientRisk
|
||||
DELETE [lr]
|
||||
FROM @tbl_to_del [d]
|
||||
INNER JOIN [Documedis_ClinicalDecisionSupport_LogDataPatientRisk] [lr] ON [lr].[DocumedisClinicalDecisionSupportLogData_FK] = [d].[DocumedisClinicalDecisionSupportLogData_PK];
|
||||
-- endregion
|
||||
|
||||
-- region logData
|
||||
SELECT 1
|
||||
FROM @tbl_to_del [d]
|
||||
INNER JOIN [Documedis_ClinicalDecisionSupport_LogData] [ld] ON [ld].[DocumedisClinicalDecisionSupportLogData_PK] = [d].[DocumedisClinicalDecisionSupportLogData_PK];
|
||||
-- endregion
|
||||
|
||||
-- region archivedRowsJournal
|
||||
SELECT 1
|
||||
FROM [archivedRowsJournal] j
|
||||
INNER JOIN @tbl_to_del [d] ON [d].[DocumedisClinicalDecisionSupportLogData_PK] = [j].[tableRowId]
|
||||
WHERE [j].[tableName]='Documedis_ClinicalDecisionSupport_LogData';
|
||||
-- endregion
|
||||
END
|
||||
END
|
||||
@@ -0,0 +1,54 @@
|
||||
USE [DocumedisLogs]
|
||||
GO
|
||||
|
||||
/*
|
||||
MDDOC-878
|
||||
|
||||
Purge of the table documedisLogs.dbo.DocumedisSecurityLogs
|
||||
|
||||
Only records that are more than 7 months old and present as archived in [archivedRowsJournal]
|
||||
will be purged.
|
||||
|
||||
Deletion is made in small batches to avoid locking.
|
||||
*/
|
||||
CREATE PROCEDURE [purge_documedisSecurityLogs] AS
|
||||
BEGIN
|
||||
DECLARE @cutoff DATE = DATEADD(MONTH, -7, CURRENT_TIMESTAMP);
|
||||
DECLARE @batch INT = 5000;
|
||||
DECLARE @row_count INT = 1
|
||||
DECLARE @tbl_to_del TABLE([DocumedisSecurityLogId] BIGINT NOT NULL);
|
||||
|
||||
WHILE @row_count > 0 BEGIN
|
||||
TRUNCATE TABLE @tbl_to_del;
|
||||
|
||||
-- region populate filter table
|
||||
INSERT INTO @tbl_to_del([DocumedisSecurityLogId])
|
||||
SELECT TOP (@batch)
|
||||
[s].[DocumedisSecurityLogId]
|
||||
FROM [DocumedisSecurityLogs] [s]
|
||||
WHERE [s].[LogDateTime] > @cutoff
|
||||
AND EXISTS(
|
||||
SELECT 1
|
||||
FROM [archivedRowsJournal] [j]
|
||||
WHERE [j].[tableName] = 'DocumedisSecurityLogs'
|
||||
AND [j].[tableRowId] = [s].[DocumedisSecurityLogId]
|
||||
);
|
||||
|
||||
SELECT @row_count = COUNT(1)
|
||||
FROM @tbl_to_del;
|
||||
-- endregion
|
||||
|
||||
-- region DocumedisSecurityLogs
|
||||
DELETE [s]
|
||||
FROM @tbl_to_del [d]
|
||||
INNER JOIN [dbo].[DocumedisSecurityLogs] [s] ON [s].[DocumedisSecurityLogId] = [d].[DocumedisSecurityLogId];
|
||||
-- endregion
|
||||
|
||||
-- region archivedRowsJournal
|
||||
DELETE [j]
|
||||
FROM [archivedRowsJournal] [j]
|
||||
INNER JOIN @tbl_to_del [d] ON [d].[DocumedisSecurityLogId] = [j].[tableRowId]
|
||||
WHERE [tableName] = 'DocumedisSecurityLogs'
|
||||
-- endregion
|
||||
END
|
||||
END
|
||||
@@ -0,0 +1,55 @@
|
||||
USE [DocumedisLogs]
|
||||
GO
|
||||
|
||||
/*
|
||||
MDDOC-878
|
||||
|
||||
Purge of the table documedisLogs.dbo.Documedis_VaccinationCheck_LogData
|
||||
|
||||
Only records that are more than 7 months old and present as archived in [archivedRowsJournal]
|
||||
will be purged.
|
||||
|
||||
Deletion is made in small batches to avoid locking.
|
||||
*/
|
||||
CREATE PROCEDURE [purge_Documedis_VaccinationCheck_LogData] AS
|
||||
BEGIN
|
||||
DECLARE @cutoff DATE = DATEADD(MONTH, -7, CURRENT_TIMESTAMP);
|
||||
DECLARE @batch INT = 5000;
|
||||
DECLARE @row_count INT = 1
|
||||
DECLARE @tbl_to_del TABLE (DocumedisVaccinationCheckLogData_PK BIGINT NOT NULL );
|
||||
|
||||
WHILE @row_count > 0 BEGIN
|
||||
TRUNCATE TABLE @tbl_to_del;
|
||||
|
||||
-- region populate filter table
|
||||
INSERT INTO @tbl_to_del([DocumedisVaccinationCheckLogData_PK])
|
||||
SELECT TOP (@batch)
|
||||
[s].[DocumedisVaccinationCheckLogData_PK]
|
||||
FROM [dbo].[Documedis_VaccinationCheck_LogData] [s]
|
||||
WHERE [s].[LogDateTime] > @cutoff
|
||||
AND EXISTS(
|
||||
SELECT 1
|
||||
FROM [archivedRowsJournal] [a]
|
||||
WHERE [a].[tableName] = 'Documedis_VaccinationCheck_LogData'
|
||||
AND [a].[tableRowId] = [s].[DocumedisVaccinationCheckLogData_PK]
|
||||
);
|
||||
|
||||
SELECT @row_count = COUNT(1)
|
||||
FROM @tbl_to_del;
|
||||
-- endregion
|
||||
|
||||
-- region Documedis_VaccinationCheck_LogData
|
||||
DELETE [d]
|
||||
FROM @tbl_to_del d
|
||||
INNER JOIN [Documedis_VaccinationCheck_LogData] s ON [s].[DocumedisVaccinationCheckLogData_PK] = [d].[DocumedisVaccinationCheckLogData_PK];
|
||||
-- endregion
|
||||
|
||||
-- region archivedRowsJournal
|
||||
DELETE j
|
||||
FROM [archivedRowsJournal] j
|
||||
INNER JOIN @tbl_to_del d ON [j].[tableRowId] = [d].[DocumedisVaccinationCheckLogData_PK]
|
||||
WHERE [j].[tableName]='Documedis_VaccinationCheck_LogData';
|
||||
-- endregion
|
||||
|
||||
END
|
||||
END
|
||||
Reference in New Issue
Block a user