generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
merging in latest changes from main
Showing
31 changed files
with
524 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
terraform/environments/delius-core/modules/components/oracle_db_shared/dms_secrets.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Database Read Access | ||
resource "aws_secretsmanager_secret" "dms_audit_endpoint_source" { | ||
name = local.dms_audit_endpoint_source_secret_name | ||
description = "Database Endpoint for Reading Audited Interaction Replication Data" | ||
kms_key_id = var.account_config.kms_keys.general_shared | ||
tags = var.tags | ||
} | ||
|
||
data "aws_iam_policy_document" "dms_audit_endpoint_source" { | ||
statement { | ||
sid = "DMSRoleToReadTheSecret" | ||
effect = "Allow" | ||
principals { | ||
type = "AWS" | ||
identifiers = ["arn:aws:iam::${local.delius_account_id}:role/DMSSecretsManagerAccessRole"] | ||
} | ||
actions = ["secretsmanager:GetSecretValue"] | ||
resources = [aws_secretsmanager_secret.dms_audit_endpoint_source.arn] | ||
} | ||
} | ||
|
||
resource "aws_secretsmanager_secret_policy" "dms_audit_endpoint_source" { | ||
secret_arn = aws_secretsmanager_secret.dms_audit_endpoint_source.arn | ||
policy = data.aws_iam_policy_document.dms_audit_endpoint_source.json | ||
} | ||
|
||
|
||
# ASM Read Access | ||
resource "aws_secretsmanager_secret" "dms_asm_endpoint_source" { | ||
name = local.dms_asm_endpoint_source_secret_name | ||
description = "ASM Endpoint" | ||
kms_key_id = var.account_config.kms_keys.general_shared | ||
tags = var.tags | ||
} | ||
|
||
data "aws_iam_policy_document" "dms_asm_endpoint_source" { | ||
statement { | ||
sid = "DMSRoleToReadTheSecret" | ||
effect = "Allow" | ||
principals { | ||
type = "AWS" | ||
identifiers = ["arn:aws:iam::${local.delius_account_id}:role/DMSSecretsManagerAccessRole"] | ||
} | ||
actions = ["secretsmanager:GetSecretValue"] | ||
resources = [aws_secretsmanager_secret.dms_asm_endpoint_source.arn] | ||
} | ||
} | ||
|
||
resource "aws_secretsmanager_secret_policy" "dms_asm_endpoint_source" { | ||
secret_arn = aws_secretsmanager_secret.dms_asm_endpoint_source.arn | ||
policy = data.aws_iam_policy_document.dms_asm_endpoint_source.json | ||
} | ||
|
||
|
||
# Database Write Access | ||
resource "aws_secretsmanager_secret" "dms_audit_endpoint_target" { | ||
name = local.dms_audit_endpoint_source_secret_name | ||
description = "Database Endpoint for Writing Audited Interaction Replication Data" | ||
kms_key_id = var.account_config.kms_keys.general_shared | ||
tags = var.tags | ||
} | ||
|
||
data "aws_iam_policy_document" "dms_audit_endpoint_target" { | ||
statement { | ||
sid = "DMSRoleToReadTheSecret" | ||
effect = "Allow" | ||
principals { | ||
type = "AWS" | ||
identifiers = ["arn:aws:iam::${local.delius_account_id}:role/DMSSecretsManagerAccessRole"] | ||
} | ||
actions = ["secretsmanager:GetSecretValue"] | ||
resources = [aws_secretsmanager_secret.dms_audit_endpoint_target.arn] | ||
} | ||
} | ||
|
||
resource "aws_secretsmanager_secret_policy" "dms_audit_endpoint_target" { | ||
secret_arn = aws_secretsmanager_secret.dms_audit_endpoint_target.arn | ||
policy = data.aws_iam_policy_document.dms_audit_endpoint_target.json | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...s/electronic-monitoring-data/modules/dms/RDS_MSSQLServer_DB_Scripts/D_Comments_V2_DDL.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
SET ANSI_NULLS ON | ||
GO | ||
SET QUOTED_IDENTIFIER ON | ||
GO | ||
CREATE TABLE [dbo].[D_Comments_V2]( | ||
[CommentSID] [int] IDENTITY(1,1) NOT NULL, | ||
[VisitID] [int] NULL, | ||
[ActivityID] [uniqueidentifier] NULL, | ||
[Comments] [varchar](4200) NULL, | ||
[CommentType] [varchar](50) NULL | ||
) ON [PRIMARY] | ||
GO | ||
CREATE CLUSTERED INDEX [PK_D_Comments_V2] ON [dbo].[D_Comments_V2] | ||
( | ||
[CommentSID] ASC | ||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
GO | ||
SET ANSI_PADDING ON | ||
GO | ||
CREATE NONCLUSTERED INDEX [I1_D_Comments_V2] ON [dbo].[D_Comments_V2] | ||
( | ||
[VisitID] ASC, | ||
[CommentType] ASC | ||
) | ||
INCLUDE([CommentSID]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
GO | ||
SET ANSI_PADDING ON | ||
GO | ||
CREATE NONCLUSTERED INDEX [I2_D_Comments_V2] ON [dbo].[D_Comments_V2] | ||
( | ||
[CommentType] ASC | ||
) | ||
INCLUDE([CommentSID],[ActivityID]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
GO | ||
CREATE NONCLUSTERED INDEX [I3_D_Comments_V2] ON [dbo].[D_Comments_V2] | ||
( | ||
[VisitID] ASC, | ||
[ActivityID] ASC | ||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
GO | ||
SET ANSI_PADDING ON | ||
GO | ||
CREATE NONCLUSTERED INDEX [I4_D_Comments_V2] ON [dbo].[D_Comments_V2] | ||
( | ||
[ActivityID] ASC, | ||
[CommentType] ASC | ||
) | ||
INCLUDE([CommentSID]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | ||
GO | ||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Database ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'D_Comments_V2', @level2type=N'COLUMN',@level2name=N'CommentSID' | ||
GO | ||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Database ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'D_Comments_V2', @level2type=N'COLUMN',@level2name=N'VisitID' | ||
GO | ||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Database ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'D_Comments_V2', @level2type=N'COLUMN',@level2name=N'ActivityID' | ||
GO | ||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Free text comments summarising either a phone call or a visit adding detail that isnt captured else where ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'D_Comments_V2', @level2type=N'COLUMN',@level2name=N'Comments' | ||
GO | ||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'identifies if the comment belongs to either a phone call or a visit' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'D_Comments_V2', @level2type=N'COLUMN',@level2name=N'CommentType' | ||
GO |
31 changes: 31 additions & 0 deletions
31
...nitoring-data/modules/dms/RDS_MSSQLServer_DB_Scripts/D_Comments_V2_Insert_Into_Select.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
SET IDENTITY_INSERT g4s_cap_dw.dbo.D_Comments_V2 ON | ||
; | ||
|
||
truncate table [g4s_cap_dw].[dbo].[D_Comments_V2]; | ||
|
||
INSERT INTO g4s_cap_dw.dbo.D_Comments_V2 (CommentSID, VisitID, ActivityID, Comments, CommentType) | ||
SELECT CommentSID, VisitID, ActivityID, | ||
trim(replace(replace(Comments, char(141), ''), char(129), '')) AS Comments, | ||
CommentType | ||
FROM g4s_cap_dw.dbo.D_Comments | ||
; | ||
|
||
SET IDENTITY_INSERT g4s_cap_dw.dbo.D_Comments_V2 OFF; | ||
|
||
|
||
-- TESTING QUERIES -- | ||
-- | ||
-- SELECT COUNT(*) FROM g4s_cap_dw.dbo.D_Comments_V2; -- 49695569 | ||
-- SELECT COUNT(*) FROM g4s_cap_dw.dbo.D_Comments; -- 49695569 | ||
-- | ||
|
||
|
||
-- | ||
-- SELECT 'D_Comments' AS TableName, Comments | ||
-- FROM g4s_cap_dw.dbo.D_Comments | ||
-- WHERE CommentSID = 26837791 | ||
-- UNION | ||
-- SELECT 'D_Comments_V2' AS TableName, Comments | ||
-- FROM g4s_cap_dw.dbo.D_Comments_V2 | ||
-- WHERE CommentSID = 26837791 | ||
-- |
Oops, something went wrong.