Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add policy configuration db table #1432

Merged
merged 4 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 34 additions & 5 deletions database/mssql/scripts/utility/add-audit-columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ SET QUOTED_IDENTIFIER ON
GO

ALTER TABLE [dbo].[TABLENAME] ADD
[CONCURRENCY_CONTROL_NUMBER] [int] NULL,
[DB_CREATE_USERID] [varchar](63) NOT NULL,
[DB_CREATE_TIMESTAMP] [datetime2](7) NOT NULL,
[DB_LAST_UPDATE_USERID] [varchar](63) NOT NULL,
[DB_LAST_UPDATE_TIMESTAMP] [datetime2](7) NOT NULL;
[APP_CREATE_TIMESTAMP] [datetime2](7) NULL,
[APP_CREATE_USERID] [nvarchar](30) NULL,
[APP_CREATE_USER_GUID] [char](32) NULL,
[APP_CREATE_USER_DIRECTORY] [nvarchar](30) NULL,
[APP_LAST_UPDATE_TIMESTAMP] [datetime2](7) NULL,
[APP_LAST_UPDATE_USER_GUID] [char](32) NULL,
[APP_LAST_UPDATE_USER_DIRECTORY] [nvarchar](30) NULL,
[CONCURRENCY_CONTROL_NUMBER] [int] NULL,
[DB_CREATE_USERID] [varchar](63) NOT NULL,
[DB_CREATE_TIMESTAMP] [datetime2](7) NOT NULL,
[DB_LAST_UPDATE_USERID] [varchar](63) NOT NULL,
[DB_LAST_UPDATE_TIMESTAMP] [datetime2](7) NOT NULL


ALTER TABLE [dbo].[TABLENAME] ADD CONSTRAINT [DF_TABLENAME_DB_LAST_UPDATE_USERID] DEFAULT (user_name()) FOR [DB_LAST_UPDATE_USERID]
GO
Expand All @@ -30,6 +38,27 @@ GO
ALTER TABLE [dbo].[TABLENAME] ADD CONSTRAINT [DF_TABLENAME_DB_LAST_UPDATE_TIMESTAMP] DEFAULT (getutcdate()) FOR [DB_LAST_UPDATE_TIMESTAMP]
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'The date and time the record was created by the application.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1Name=N'TABLENAME', @level2type=N'COLUMN',@level2name=N'APP_CREATE_TIMESTAMP'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'The userid of the application user that created the record.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1Name=N'TABLENAME', @level2type=N'COLUMN',@level2name=N'APP_CREATE_USERID'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'The guid of the application user that created the record.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1Name=N'TABLENAME', @level2type=N'COLUMN',@level2name=N'APP_CREATE_USER_GUID'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'The directory of the application user that created the record.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1Name=N'TABLENAME', @level2type=N'COLUMN',@level2name=N'APP_CREATE_USER_DIRECTORY'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'The date and time the record was last updated by the application.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1Name=N'TABLENAME', @level2type=N'COLUMN',@level2name=N'APP_LAST_UPDATE_TIMESTAMP'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'The guid of the application user that last updated the record.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1Name=N'TABLENAME', @level2type=N'COLUMN',@level2name=N'APP_LAST_UPDATE_USER_GUID'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'The directory of the application user that last updated the record.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1Name=N'TABLENAME', @level2type=N'COLUMN',@level2name=N'APP_LAST_UPDATE_USER_DIRECTORY'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Application code is responsible for retrieving the row and then incrementing the value of the CONCURRENCY_CONTROL_NUMBER column by one prior to issuing an update. If this is done then the update will succeed, provided that the row was not updated by any other transactions in the period between the read and the update operations.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1Name=N'TABLENAME', @level2type=N'COLUMN',@level2name=N'CONCURRENCY_CONTROL_NUMBER'
GO

Expand Down
43 changes: 43 additions & 0 deletions database/mssql/scripts/versions/revert/v_29_ddl_revert.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET NOCOUNT ON
GO

SET XACT_ABORT ON

BEGIN TRY
BEGIN TRANSACTION
DROP TABLE [dbo].[ORBC_POLICY_CONFIGURATION_HIST]
DROP TABLE [dbo].[ORBC_POLICY_CONFIGURATION]
DROP SEQUENCE [dbo].[ORBC_POLICY_CONFIGURATION_H_ID_SEQ]

DROP TRIGGER [permit].[ORBC_CFSTRDT_A_S_IUD_TR]
DROP TABLE [permit].[ORBC_CFS_TRANSACTION_DETAIL_HIST]
DROP SEQUENCE [permit].[ORBC_CFS_TRANSACTION_DETAIL_H_ID_SEQ]

DROP TRIGGER [permit].[ORBC_CRACCACT_A_S_IUD_TR]
DROP TABLE [permit].[ORBC_CREDIT_ACCOUNT_ACTIVITY_HIST]
DROP SEQUENCE [permit].[ORBC_CREDIT_ACCOUNT_ACTIVITY_H_ID_SEQ]

DROP TRIGGER [permit].[ORBC_CRACC_A_S_IUD_TR]
DROP TABLE [permit].[ORBC_CREDIT_ACCOUNT_HIST]
DROP SEQUENCE [permit].[ORBC_CREDIT_ACCOUNT_H_ID_SEQ]

DROP TRIGGER [permit].[ORBC_CRACCUSR_A_S_IUD_TR]
DROP TABLE [permit].[ORBC_CREDIT_ACCOUNT_USER_HIST]
DROP SEQUENCE [permit].[ORBC_CREDIT_ACCOUNT_USER_H_ID_SEQ]
COMMIT
END TRY

BEGIN CATCH
IF @@TRANCOUNT > 0
ROLLBACK;
THROW
END CATCH

DECLARE @VersionDescription VARCHAR(255)
SET @VersionDescription = 'Reverting policy configuration table creation plus history tables for v28 and v27'

INSERT [dbo].[ORBC_SYS_VERSION] ([VERSION_ID], [DESCRIPTION], [RELEASE_DATE]) VALUES (28, @VersionDescription, getutcdate())
6 changes: 3 additions & 3 deletions database/mssql/scripts/versions/v_28_ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ INSERT [permit].[ORBC_CREDIT_ACCOUNT_STATUS_TYPE] (
[DESCRIPTION]
)
VALUES (
N'SETUP',
N'SETUP'
N'SETUP_FAIL',
N'SETUP_FAIL'
)

IF @@ERROR <> 0 SET NOEXEC ON
Expand Down Expand Up @@ -291,7 +291,7 @@ IF @@ERROR <> 0 SET NOEXEC ON
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Unique auto-generated surrogate primary key' , @level0type=N'SCHEMA',@level0name=N'permit', @level1type=N'TABLE',@level1name=N'ORBC_CREDIT_ACCOUNT', @level2type=N'COLUMN',@level2name=N'CREDIT_ACCOUNT_ID'
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'The company who is the account holder of the credit account' , @level0type=N'SCHEMA',@level0name=N'permit', @level1type=N'TABLE',@level1Name=N'ORBC_CREDIT_ACCOUNT', @level2type=N'COLUMN',@level2name=N'COMPANY_ID'
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'The status of the credit account - ONHOLD, ACTIVE, CLOSED, SETUP' , @level0type=N'SCHEMA',@level0name=N'permit', @level1type=N'TABLE',@level1Name=N'ORBC_CREDIT_ACCOUNT', @level2type=N'COLUMN',@level2name=N'CREDIT_ACCOUNT_STATUS_TYPE'
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'The status of the credit account - ONHOLD, ACTIVE, CLOSED, SETUP_FAIL' , @level0type=N'SCHEMA',@level0name=N'permit', @level1type=N'TABLE',@level1Name=N'ORBC_CREDIT_ACCOUNT', @level2type=N'COLUMN',@level2name=N'CREDIT_ACCOUNT_STATUS_TYPE'
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'The type of credit account - PREPAID, UNSECURED, SECURED' , @level0type=N'SCHEMA',@level0name=N'permit', @level1type=N'TABLE',@level1Name=N'ORBC_CREDIT_ACCOUNT', @level2type=N'COLUMN',@level2name=N'CREDIT_ACCOUNT_TYPE'
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'The primary key of the client in CFS' , @level0type=N'SCHEMA',@level0name=N'permit', @level1type=N'TABLE',@level1Name=N'ORBC_CREDIT_ACCOUNT', @level2type=N'COLUMN',@level2name=N'CFS_PARTY_NUMBER'
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'The primary key of the site associated with the party in CFS' , @level0type=N'SCHEMA',@level0name=N'permit', @level1type=N'TABLE',@level1Name=N'ORBC_CREDIT_ACCOUNT', @level2type=N'COLUMN',@level2name=N'CFS_SITE_NUMBER'
Expand Down
Loading