Skip to content

Commit b7a0ac6

Browse files
authored
Merge pull request #39 from data-solution-automation-engine/31-update-all-post-deployment-scripts-to-merge-to-target
update all remaining post deploy scripts
2 parents ab5cf52 + 0dbba8b commit b7a0ac6

8 files changed

+211
-96
lines changed

Direct_Framework/DeploymentScripts/3-PostDeployment/omd_metadata.AREA.sql

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,29 @@
33
* Reference data insert and update script
44
* DIRECT Framework v2.0
55
*
6+
* Reference metadata table AREA stores areas and layers information.
7+
*
8+
* This script is used to insert and update reference data on deployment.
9+
* Any bespoke event types added manually to the target will be retained,
10+
* as long as the keys differ.
11+
*
12+
* To maintain a clean CI/CD process, consider using this script to manage
13+
* all reference data for event types.
14+
*
615
* [omd_metadata].[AREA]
716
*
817
******************************************************************************/
18+
919
SET NOCOUNT ON;
1020

11-
INSERT INTO [omd_metadata].[AREA]
12-
SELECT [AREA_CODE], [LAYER_CODE], [AREA_DESCRIPTION]
13-
FROM (
14-
/* AREA_CODE, LAYER_CODE, AREA_DESCRIPTION */
15-
VALUES
21+
DECLARE @tblMerge TABLE(
22+
[AREA_CODE] NVARCHAR (100) NOT NULL PRIMARY KEY CLUSTERED,
23+
[LAYER_CODE] NVARCHAR (100) NOT NULL,
24+
[AREA_DESCRIPTION] NVARCHAR (4000) NULL
25+
);
26+
27+
INSERT INTO @tblMerge([AREA_CODE], [LAYER_CODE], [AREA_DESCRIPTION])
28+
VALUES
1629
(N'HELPER', N'Presentation', N'The Helper Area'),
1730
(N'INT', N'Integration', N'The Base Integration Area'),
1831
(N'INTPR', N'Integration', N'The Derived Integration Area'),
@@ -22,11 +35,22 @@ FROM (
2235
(N'PSA', N'Staging', N'The Persistent Staging Area'),
2336
(N'STG', N'Staging', N'The Staging Area of the Staging Layer'),
2437
(N'SYNC', N'Staging', N'Synchronization of the production History Area of the Staging Layer for build and test')
25-
) AS refData(AREA_CODE, LAYER_CODE, AREA_DESCRIPTION)
26-
WHERE NOT EXISTS (
27-
SELECT NULL
28-
FROM [omd_metadata].[AREA] a
29-
WHERE a.AREA_CODE = refData.AREA_CODE
30-
);
38+
39+
MERGE [omd_metadata].[AREA] AS TARGET
40+
USING @tblMerge AS src
41+
ON TARGET.[AREA_CODE] = src.[AREA_CODE]
42+
43+
WHEN MATCHED THEN
44+
UPDATE
45+
SET [LAYER_CODE] = src.[LAYER_CODE],
46+
[AREA_DESCRIPTION] = src.[AREA_DESCRIPTION]
47+
48+
WHEN NOT MATCHED THEN
49+
INSERT ([AREA_CODE]
50+
,[LAYER_CODE]
51+
,[AREA_DESCRIPTION])
52+
VALUES ([AREA_CODE]
53+
,[LAYER_CODE]
54+
,[AREA_DESCRIPTION]);
3155

3256
GO

Direct_Framework/DeploymentScripts/3-PostDeployment/omd_metadata.EVENT_TYPE.sql

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ DECLARE @tblMerge TABLE(
2323

2424
INSERT INTO @tblMerge([EVENT_TYPE_CODE], [EVENT_TYPE_CODE_DESCRIPTION])
2525
VALUES
26-
(N'1', N'Infrastructure error.'),
27-
(N'2', N'Internal data integration process error or system generated event.'),
28-
(N'3', N'Custom exception handling that has been implemented in code (Error Bitmaps).')
26+
(N'1', N'Infrastructure error.'),
27+
(N'2', N'Internal data integration process error or system generated event.'),
28+
(N'3', N'Custom exception handling that has been implemented in code (Error Bitmaps).')
2929

3030
MERGE [omd_metadata].[EVENT_TYPE] AS TARGET
3131
USING @tblMerge AS src
32-
ON TARGET.[EVENT_TYPE_CODE] = src.[EVENT_TYPE_CODE]
32+
ON TARGET.[EVENT_TYPE_CODE] = src.[EVENT_TYPE_CODE]
3333

3434
WHEN MATCHED THEN
35-
UPDATE
36-
SET [EVENT_TYPE_CODE_DESCRIPTION] = src.[EVENT_TYPE_CODE_DESCRIPTION]
35+
UPDATE
36+
SET [EVENT_TYPE_CODE_DESCRIPTION] = src.[EVENT_TYPE_CODE_DESCRIPTION]
3737

3838
WHEN NOT MATCHED THEN
39-
INSERT ([EVENT_TYPE_CODE]
40-
,[EVENT_TYPE_CODE_DESCRIPTION])
41-
VALUES ([EVENT_TYPE_CODE]
42-
,[EVENT_TYPE_CODE_DESCRIPTION]);
39+
INSERT ([EVENT_TYPE_CODE]
40+
,[EVENT_TYPE_CODE_DESCRIPTION])
41+
VALUES ([EVENT_TYPE_CODE]
42+
,[EVENT_TYPE_CODE_DESCRIPTION]);
4343

4444
GO

Direct_Framework/DeploymentScripts/3-PostDeployment/omd_metadata.EXECUTION_STATUS.sql

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,45 @@
22
* https://github.com/data-solution-automation-engine/DIRECT
33
* Reference data insert and update script
44
* DIRECT Framework v2.0
5+
6+
* Reference metadata table EXECUTION_STATUS stores execution status codes and descriptions.
7+
* This script is used to insert and update reference data on deployment.
8+
* Any bespoke execution status codes added manually to the target will be retained,
9+
* as long as the keys differ.
10+
* To maintain a clean CI/CD process, consider using this script to manage
11+
* all reference data for execution status codes.
512
*
613
* [omd_metadata].[EXECUTION_STATUS]
714
*
815
******************************************************************************/
916

1017
SET NOCOUNT ON;
1118

12-
INSERT INTO [omd_metadata].[EXECUTION_STATUS]
13-
SELECT *
14-
FROM (
15-
/* EXECUTION_STATUS_CODE, EXECUTION_STATUS_DESCRIPTION */
16-
VALUES
19+
DECLARE @tblMerge TABLE(
20+
[EXECUTION_STATUS_CODE] NVARCHAR (100) NOT NULL PRIMARY KEY CLUSTERED,
21+
[EXECUTION_STATUS_DESCRIPTION] NVARCHAR (4000) NULL
22+
);
23+
24+
INSERT INTO @tblMerge([EXECUTION_STATUS_CODE], [EXECUTION_STATUS_DESCRIPTION])
25+
VALUES
1726
(N'Aborted', N'An abort is an attempted execution which led to the instance unable to start. Abort means that the process did not run, but was supposed to. This is typically the result of incorrect configuration or race conditions in the orchestration. The most common reasons for an abort is that another instance of the same Batch or Module is already running. The same logical unit of processing can never run more than once at the same time to maintain data consistency. If this situation is detected the second process will abort before any data is processed. The Module (Instance) was executed from a parent Batch (Instance) but not registered as such in the Batch/Module relationship.'),
1827
(N'Cancelled', N'The cancelled (skipped) status code indicates that the instance was attempted to be executed, but that the control framework found that it was not necessary to run the process. This can be due to Modules or Batches being disabled in the framework using the Active Indicator. Disabling processes can be done at Batch, Batch/Module and Module level. Another common scenario is that, when Batches are restarted, earlier successful Modules in that Batch will not be reprocessed. These Module Instances will be skipped / cancelled until the full Batch has completed successfully. This is to prevents data loss.'),
1928
(N'Executing', N'The instance is currently running (executing). This is a transient state only, for when the process is actually running. As soon as it is completed this code will be updated to one of the end-state execution codes.'),
2029
(N'Failed', N'The instance is no longer running after completing with failures.'),
2130
(N'Succeeded', N'The instance is no longer running after successful completion of the process.')
22-
) AS refData(EXECUTION_STATUS_CODE, EXECUTION_STATUS_DESCRIPTION)
23-
WHERE NOT EXISTS (
24-
SELECT NULL
25-
FROM [omd_metadata].[EXECUTION_STATUS] es
26-
WHERE es.EXECUTION_STATUS_CODE = refData.EXECUTION_STATUS_CODE
27-
);
31+
32+
MERGE [omd_metadata].[EXECUTION_STATUS] AS TARGET
33+
USING @tblMerge AS src
34+
ON TARGET.[EXECUTION_STATUS_CODE] = src.[EXECUTION_STATUS_CODE]
35+
36+
WHEN MATCHED THEN
37+
UPDATE
38+
SET [EXECUTION_STATUS_DESCRIPTION] = src.[EXECUTION_STATUS_DESCRIPTION]
39+
40+
WHEN NOT MATCHED THEN
41+
INSERT ([EXECUTION_STATUS_CODE]
42+
,[EXECUTION_STATUS_DESCRIPTION])
43+
VALUES ([EXECUTION_STATUS_CODE]
44+
,[EXECUTION_STATUS_DESCRIPTION]);
2845

2946
GO

Direct_Framework/DeploymentScripts/3-PostDeployment/omd_metadata.FRAMEWORK_METADATA.sql

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,52 @@
33
* Reference data insert and update script
44
* DIRECT Framework v2.0
55
*
6+
* Reference metadata table FRAMEWORK_METADATA stores metadata information.
7+
* This script is used to insert and update reference data on deployment.
8+
* Any bespoke metadata added manually to the target will be retained,
9+
* as long as the keys differ.
10+
* To maintain a clean CI/CD process, consider using this script to manage
11+
* all reference data for metadata.
12+
*
613
* [omd_metadata].[FRAMEWORK_METADATA]
714
*
815
******************************************************************************/
916

1017
SET NOCOUNT ON;
1118

12-
INSERT INTO [omd_metadata].[FRAMEWORK_METADATA]
13-
SELECT *
14-
FROM (
15-
/* [CODE], [VALUE], [GROUP], [DESCRIPTION], [ACTIVE_INDICATOR] */
16-
VALUES
17-
(
18-
N'DIRECT_VERSION', N'2.0.0.0', N'SYSTEM_METADATA',
19-
N'The current version of the DIRECT Framework and database', 'Y'
20-
)
21-
) AS refData
22-
(
23-
[CODE], [VALUE], [GROUP], [DESCRIPTION], [ACTIVE_INDICATOR]
24-
)
25-
WHERE NOT EXISTS (
26-
SELECT NULL
27-
FROM [omd_metadata].[FRAMEWORK_METADATA] m
28-
WHERE m.[CODE] = refData.[CODE]
19+
DECLARE @tblMerge TABLE(
20+
[CODE] NVARCHAR (100) NOT NULL PRIMARY KEY CLUSTERED,
21+
[VALUE] NVARCHAR (4000) NULL,
22+
[GROUP] NVARCHAR (100) NOT NULL,
23+
[DESCRIPTION] NVARCHAR (4000) NULL,
24+
[ACTIVE_INDICATOR] CHAR(1) NOT NULL
2925
);
3026

27+
INSERT INTO @tblMerge([CODE], [VALUE], [GROUP], [DESCRIPTION], [ACTIVE_INDICATOR])
28+
VALUES
29+
(N'DIRECT_VERSION', N'2.0.0.0', N'SYSTEM_METADATA', N'The current version of the DIRECT Framework and database', 'Y')
30+
31+
MERGE [omd_metadata].[FRAMEWORK_METADATA] AS TARGET
32+
USING @tblMerge AS src
33+
ON TARGET.[CODE] = src.[CODE]
34+
35+
WHEN MATCHED THEN
36+
UPDATE
37+
SET [VALUE] = src.[VALUE],
38+
[GROUP] = src.[GROUP],
39+
[DESCRIPTION] = src.[DESCRIPTION],
40+
[ACTIVE_INDICATOR] = src.[ACTIVE_INDICATOR]
41+
42+
WHEN NOT MATCHED THEN
43+
INSERT ([CODE]
44+
,[VALUE]
45+
,[GROUP]
46+
,[DESCRIPTION]
47+
,[ACTIVE_INDICATOR])
48+
VALUES ([CODE]
49+
,[VALUE]
50+
,[GROUP]
51+
,[DESCRIPTION]
52+
,[ACTIVE_INDICATOR]);
53+
3154
GO

Direct_Framework/DeploymentScripts/3-PostDeployment/omd_metadata.FREQUENCY.sql

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
* Reference data insert and update script
44
* DIRECT Framework v2.0
55
*
6-
* Reference metadata table FREQUENCY
7-
* TODO: Add description
6+
* Reference metadata table FREQUENCY stores frequency information.
7+
* This table is used to define the frequency of the processing unit.
8+
* This script is used to insert and update reference data on deployment.
9+
* Any bespoke frequency added manually to the target will be retained,
10+
* as long as the keys differ.
11+
* To maintain a clean CI/CD process, consider using this script to manage
12+
* all reference data for frequency.
813
*
914
* [omd_metadata].[FREQUENCY]
1015
*
@@ -19,7 +24,7 @@ DECLARE @tblMerge TABLE(
1924

2025
INSERT INTO @tblMerge([FREQUENCY_CODE], [FREQUENCY_DESCRIPTION])
2126
VALUES
22-
(N'Continuous', N'Continuously running integration processing.'),
27+
(N'Continuous', N'Continuously running integration processing unit.'),
2328
(N'Triggered', N'Event triggered processing unit.'),
2429
(N'On-demand', N'On-demand processing unit.'),
2530
(N'Scheduled', N'Scheduled processing unit.')

Direct_Framework/DeploymentScripts/3-PostDeployment/omd_metadata.INTERNAL_PROCESSING_STATUS.sql

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,42 @@
33
* Reference data insert and update script
44
* DIRECT Framework v2.0
55
*
6+
* Reference metadata table INTERNAL_PROCESSING_STATUS stores internal processing status codes and descriptions.
7+
*
8+
* This script is used to insert and update reference data on deployment.
9+
* Any bespoke internal processing status codes added manually to the target will be retained,
10+
* as long as the keys differ.
11+
* To maintain a clean CI/CD process, consider using this script to manage
12+
* all reference data for internal processing status codes.
13+
*
614
* [omd_metadata].[INTERNAL_PROCESSING_STATUS]
715
*
816
******************************************************************************/
917

1018
SET NOCOUNT ON;
1119

12-
INSERT INTO [omd_metadata].[INTERNAL_PROCESSING_STATUS]
13-
SELECT *
14-
FROM (
15-
/* INTERNAL_PROCESSING_STATUS_CODE, INTERNAL_INTERNAL_PROCESSING_STATUS_DESCRIPTION */
16-
VALUES
17-
(N'Abort', N'This exception case indicates that the instance in question was executed, but that another instance of the same Batch or Module is already running (see also the equivalent Execution Status Code for additional detail). This is one of the checks performed before the regular process (Module and/or Batch) can continue. If this situation occurs, all processing should stop; no data should be processed. The process will use the Internal Processing Status `Abort` to trigger the Module/Batch `Abort` event which sets the Execution Status Code to `Cancelled`, ending the process gracefully.'),
18-
(N'Cancel', N'The instance evaluation has determined that it is not necessary to run this process (see also the equivalent Execution Status Code for additional detail). As with Abort, if the Internal Process Status code is `Cancel` then all further processing should stop after the Execution Status Code has also been updated to `Cancel`.'),
19-
(N'Proceed', N'The instance can continue on to the next processing. This is the default internal processing value; each process step will evaluate the Internal Process Status code and continue only if it is set to `Proceed`. After the pre-processing has been completed the `Proceed` value is the flag that is required to initiate the main process.'),
20-
(N'Rollback', N'The `Rollback` code is only temporarily set during rollback execution in the Module Evaluation event. This is essentially for debugging purposes. After the rollback is completed the Internal Processing Status will be set to `Proceed` again to enable the continuation of the process.')
21-
) AS refData(INTERNAL_PROCESSING_STATUS_CODE, INTERNAL_PROCESSING_STATUS_DESCRIPTION)
22-
WHERE NOT EXISTS (
23-
SELECT NULL
24-
FROM [omd_metadata].[INTERNAL_PROCESSING_STATUS] pin
25-
WHERE pin.INTERNAL_PROCESSING_STATUS_CODE = refData.INTERNAL_PROCESSING_STATUS_CODE
26-
);
20+
DECLARE @tblMerge TABLE(
21+
[INTERNAL_PROCESSING_STATUS_CODE] NVARCHAR (100) NOT NULL PRIMARY KEY CLUSTERED,
22+
[INTERNAL_PROCESSING_STATUS_DESCRIPTION] NVARCHAR (4000) NULL
23+
);
24+
25+
INSERT INTO @tblMerge([INTERNAL_PROCESSING_STATUS_CODE], [INTERNAL_PROCESSING_STATUS_DESCRIPTION])
26+
VALUES
27+
(N'Abort', N'This exception case indicates that the instance in question was executed, but that another instance of the same Batch or Module is already running (see also the equivalent Execution Status Code for additional detail). This is one of the checks performed before the regular process (Module and/or Batch) can continue. If this situation occurs, all processing should stop; no data should be processed. The process will use the Internal Processing Status `Abort` to trigger the Module/Batch `Abort` event which sets the Execution Status Code to `Cancelled`, ending the process gracefully.'),
28+
(N'Cancel', N'The instance evaluation has determined that it is not necessary to run this process (see also the equivalent Execution Status Code for additional detail). As with Abort, if the Internal Process Status code is `Cancel` then all further processing should stop after the Execution Status Code has also been updated to `Cancel`.'),
29+
(N'Proceed', N'The instance can continue on to the next processing. This is the default internal processing value; each process step will evaluate the Internal Process Status code and continue only if it is set to `Proceed`. After the pre-processing has been completed the `Proceed` value is the flag that is required to initiate the main process.'),
30+
(N'Rollback', N'The `Rollback` code is only temporarily set during rollback execution in the Module Evaluation event. This is essentially for debugging purposes. After the rollback is completed the Internal Processing Status will be set to `Proceed` again to enable the continuation of the process.');
31+
32+
MERGE [omd_metadata].[INTERNAL_PROCESSING_STATUS] AS TARGET
33+
USING @tblMerge AS src
34+
ON TARGET.[INTERNAL_PROCESSING_STATUS_CODE] = src.[INTERNAL_PROCESSING_STATUS_CODE]
35+
WHEN MATCHED THEN
36+
UPDATE
37+
SET [INTERNAL_PROCESSING_STATUS_DESCRIPTION] = src.[INTERNAL_PROCESSING_STATUS_DESCRIPTION]
38+
WHEN NOT MATCHED THEN
39+
INSERT ([INTERNAL_PROCESSING_STATUS_CODE]
40+
,[INTERNAL_PROCESSING_STATUS_DESCRIPTION])
41+
VALUES ([INTERNAL_PROCESSING_STATUS_CODE]
42+
,[INTERNAL_PROCESSING_STATUS_DESCRIPTION]);
2743

2844
GO

Direct_Framework/DeploymentScripts/3-PostDeployment/omd_metadata.LAYER.sql

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,42 @@
33
* Reference data insert and update script
44
* DIRECT Framework v2.0
55
*
6+
* Reference metadata table LAYER stores layer information.
7+
*
8+
* This script is used to insert and update reference data on deployment.
9+
* Any bespoke layers added manually to the target will be retained,
10+
* as long as the keys differ.
11+
* To maintain a clean CI/CD process, consider using this script to manage
12+
* all reference data for layers.
13+
*
614
* [omd_metadata].[LAYER]
715
*
816
******************************************************************************/
917

1018
SET NOCOUNT ON;
1119

12-
INSERT INTO [omd_metadata].[LAYER]
13-
SELECT *
14-
FROM
15-
(
16-
/* LAYER_CODE, in */
17-
VALUES
18-
(N'Integration', N'The Integration Layer'),
19-
(N'Presentation', N'The Presentation Layer'),
20-
(N'Staging', N'The Staging Layer'),
21-
(N'Maintenance', N'Internal Data Solution')
22-
) AS refData(LAYER_CODE, LAYER_DESCRIPTION)
23-
WHERE NOT EXISTS (
24-
SELECT NULL
25-
FROM [omd_metadata].[LAYER] l
26-
WHERE l.LAYER_CODE = refData.LAYER_CODE
20+
DECLARE @tblMerge TABLE(
21+
[LAYER_CODE] NVARCHAR (100) NOT NULL PRIMARY KEY CLUSTERED,
22+
[LAYER_DESCRIPTION] NVARCHAR (4000) NULL
2723
);
2824

25+
INSERT INTO @tblMerge([LAYER_CODE], [LAYER_DESCRIPTION])
26+
VALUES
27+
(N'Integration', N'The Integration Layer'),
28+
(N'Presentation', N'The Presentation Layer'),
29+
(N'Staging', N'The Staging Layer'),
30+
(N'Maintenance', N'Internal Data Solution')
31+
32+
MERGE [omd_metadata].[LAYER] AS TARGET
33+
USING @tblMerge AS src
34+
ON TARGET.[LAYER_CODE] = src.[LAYER_CODE]
35+
WHEN MATCHED THEN
36+
UPDATE
37+
SET [LAYER_DESCRIPTION] = src.[LAYER_DESCRIPTION]
38+
WHEN NOT MATCHED THEN
39+
INSERT ([LAYER_CODE]
40+
,[LAYER_DESCRIPTION])
41+
VALUES ([LAYER_CODE]
42+
,[LAYER_DESCRIPTION]);
43+
2944
GO

0 commit comments

Comments
 (0)