diff --git a/source/backend/api/Pims.Api.csproj b/source/backend/api/Pims.Api.csproj index 38abbd63f0..e0c0ee3b53 100644 --- a/source/backend/api/Pims.Api.csproj +++ b/source/backend/api/Pims.Api.csproj @@ -2,8 +2,8 @@ 0ef6255f-9ea0-49ec-8c65-c172304b4926 - 3.2.0-55.3 - 3.2.0-55.3 + 3.2.0-55.5 + 3.2.0-55.5 3.2.0.55 true 16BC0468-78F6-4C91-87DA-7403C919E646 diff --git a/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Down/01_PSP_PIMS_Alter_Down.sql b/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Down/01_PSP_PIMS_Alter_Down.sql index 51c6ebb94f..3d3dcbee78 100644 --- a/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Down/01_PSP_PIMS_Alter_Down.sql +++ b/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Down/01_PSP_PIMS_Alter_Down.sql @@ -1,4 +1,4 @@ --- Script generated by Aqua Data Studio Schema Synchronization for MS SQL Server 2016 on Fri May 26 13:07:41 PDT 2023 +-- Script generated by Aqua Data Studio Schema Synchronization for MS SQL Server 2016 on Tue May 30 16:17:33 PDT 2023 -- Execute this script on: -- PIMS_PSP_S55_00/dbo - This database/schema will be modified -- to synchronize it with MS SQL Server 2016: @@ -138,6 +138,15 @@ GO IF @@ERROR <> 0 SET NOEXEC ON GO +-- Drop foreign key constraint dbo.PIM_ACQNFL_PIM_INTHLD_FK +PRINT N'Drop foreign key constraint dbo.PIM_ACQNFL_PIM_INTHLD_FK' +GO +ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER] + DROP CONSTRAINT IF EXISTS [PIM_ACQNFL_PIM_INTHLD_FK] +GO +IF @@ERROR <> 0 SET NOEXEC ON +GO + -- Drop index dbo.IHPRIN_PROPERTY_ACQUISITION_FILE_ID_IDX PRINT N'Drop index dbo.IHPRIN_PROPERTY_ACQUISITION_FILE_ID_IDX' GO @@ -521,29 +530,13 @@ GO IF @@ERROR <> 0 SET NOEXEC ON GO --- Drop sequence dbo.PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ -PRINT N'Drop sequence dbo.PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ' -GO -DROP SEQUENCE IF EXISTS [dbo].[PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ] -GO -IF @@ERROR <> 0 SET NOEXEC ON -GO - -- Alter table dbo.PIMS_ACQUISITION_PAYEE PRINT N'Alter table dbo.PIMS_ACQUISITION_PAYEE' GO ---UPDATE [dbo].[PIMS_ACQUISITION_PAYEE] SET [ACQUISITION_OWNER_ID] = -1 WHERE [ACQUISITION_OWNER_ID] IS NULL ---GO ---IF @@ERROR <> 0 SET NOEXEC ON ---GO ALTER TABLE [dbo].[PIMS_ACQUISITION_PAYEE] ALTER COLUMN [ACQUISITION_OWNER_ID] bigint NOT NULL GO IF @@ERROR <> 0 SET NOEXEC ON GO ---ALTER TABLE [dbo].[PIMS_ACQUISITION_PAYEE] ADD DEFAULT -1 FOR [ACQUISITION_OWNER_ID] ---GO ---IF @@ERROR <> 0 SET NOEXEC ON ---GO ALTER TABLE [dbo].[PIMS_ACQUISITION_PAYEE] DROP COLUMN IF EXISTS [INTEREST_HOLDER_ID], [OWNER_REPRESENTATIVE_ID], [OWNER_SOLICITOR_ID], [ACQUISITION_FILE_PERSON_ID] GO @@ -553,18 +546,10 @@ GO -- Alter table dbo.PIMS_ACQUISITION_PAYEE_HIST PRINT N'Alter table dbo.PIMS_ACQUISITION_PAYEE_HIST' GO ---UPDATE [dbo].[PIMS_ACQUISITION_PAYEE_HIST] SET [ACQUISITION_OWNER_ID] = -1 WHERE [ACQUISITION_OWNER_ID] IS NULL ---GO ---IF @@ERROR <> 0 SET NOEXEC ON ---GO ALTER TABLE [dbo].[PIMS_ACQUISITION_PAYEE_HIST] ALTER COLUMN [ACQUISITION_OWNER_ID] bigint NOT NULL GO IF @@ERROR <> 0 SET NOEXEC ON GO ---ALTER TABLE [dbo].[PIMS_ACQUISITION_PAYEE_HIST] ADD DEFAULT -1 FOR [ACQUISITION_OWNER_ID] ---GO ---IF @@ERROR <> 0 SET NOEXEC ON ---GO ALTER TABLE [dbo].[PIMS_ACQUISITION_PAYEE_HIST] DROP COLUMN IF EXISTS [INTEREST_HOLDER_ID], [OWNER_REPRESENTATIVE_ID], [OWNER_SOLICITOR_ID], [ACQUISITION_FILE_PERSON_ID] GO @@ -574,6 +559,11 @@ GO -- Alter table dbo.PIMS_ACQ_PAYEE_CHEQUE PRINT N'Alter table dbo.PIMS_ACQ_PAYEE_CHEQUE' GO +ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE] + DROP CONSTRAINT IF EXISTS [AQPCHQ_IS_PAYMENT_IN_TRUST_DEF] +GO +IF @@ERROR <> 0 SET NOEXEC ON +GO ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE] ADD [IS_GST_REQUIRED] bit NULL CONSTRAINT [AQPCHQ_IS_GST_REQUIRED_DEF] DEFAULT (CONVERT([bit],(0))) GO @@ -586,7 +576,7 @@ GO IF @@ERROR <> 0 SET NOEXEC ON GO ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE] - DROP COLUMN IF EXISTS [GST_NUMBER] + DROP COLUMN IF EXISTS [GST_NUMBER], [IS_PAYMENT_IN_TRUST] GO IF @@ERROR <> 0 SET NOEXEC ON GO @@ -600,7 +590,7 @@ GO IF @@ERROR <> 0 SET NOEXEC ON GO ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE_HIST] - DROP COLUMN IF EXISTS [GST_NUMBER] + DROP COLUMN IF EXISTS [GST_NUMBER], [IS_PAYMENT_IN_TRUST] GO IF @@ERROR <> 0 SET NOEXEC ON GO @@ -612,10 +602,6 @@ ALTER TABLE [dbo].[PIMS_ACQ_CHKLST_SECTION_TYPE] DROP CONSTRAINT IF EXISTS [AQCS GO IF @@ERROR <> 0 SET NOEXEC ON GO ---ALTER TABLE [dbo].[PIMS_ACQ_CHKLST_SECTION_TYPE] ADD DEFAULT getutcdate() FOR [EFFECTIVE_DATE] ---GO ---IF @@ERROR <> 0 SET NOEXEC ON ---GO -- Alter table dbo.PIMS_ACQ_CHKLST_ITEM_TYPE PRINT N'Alter table dbo.PIMS_ACQ_CHKLST_ITEM_TYPE' @@ -624,10 +610,6 @@ ALTER TABLE [dbo].[PIMS_ACQ_CHKLST_ITEM_TYPE] DROP CONSTRAINT IF EXISTS [ACQCIT_ GO IF @@ERROR <> 0 SET NOEXEC ON GO ---ALTER TABLE [dbo].[PIMS_ACQ_CHKLST_ITEM_TYPE] ADD DEFAULT getutcdate() FOR [EFFECTIVE_DATE] ---GO ---IF @@ERROR <> 0 SET NOEXEC ON ---GO -- Create index dbo.ACQPAY_ACQUISITION_OWNER_ID_IDX PRINT N'Create index dbo.ACQPAY_ACQUISITION_OWNER_ID_IDX' diff --git a/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Down/Schema Compare.zip b/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Down/Schema Compare.zip index 531d0e2012..0edd01a803 100644 Binary files a/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Down/Schema Compare.zip and b/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Down/Schema Compare.zip differ diff --git a/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Up/002_PSP_PIMS_Alter_Up.sql b/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Up/002_PSP_PIMS_Alter_Up.sql index 9f14b45226..8fcce05d97 100644 --- a/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Up/002_PSP_PIMS_Alter_Up.sql +++ b/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Up/002_PSP_PIMS_Alter_Up.sql @@ -1,4 +1,4 @@ --- Script generated by Aqua Data Studio Schema Synchronization for MS SQL Server 2016 on Fri May 26 13:03:56 PDT 2023 +-- Script generated by Aqua Data Studio Schema Synchronization for MS SQL Server 2016 on Tue May 30 16:14:09 PDT 2023 -- Execute this script on: -- PIMS_PSP_S54_00/dbo - This database/schema will be modified -- to synchronize it with MS SQL Server 2016: @@ -63,21 +63,6 @@ GO IF @@ERROR <> 0 SET NOEXEC ON GO ----- Create sequence dbo.PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ ---PRINT N'Create sequence dbo.PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ' ---GO ---CREATE SEQUENCE [dbo].[PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ] --- AS bigint --- START WITH 1 --- INCREMENT BY 1 --- MINVALUE 1 --- MAXVALUE 2147483647 --- NO CYCLE --- CACHE 50 ---GO ---IF @@ERROR <> 0 SET NOEXEC ON ---GO - -- Create sequence dbo.PIMS_INTHLDR_PROP_INTEREST_ID_SEQ PRINT N'Create sequence dbo.PIMS_INTHLDR_PROP_INTEREST_ID_SEQ' GO @@ -128,6 +113,7 @@ PRINT N'Create table dbo.PIMS_INTEREST_HOLDER' GO CREATE TABLE [dbo].[PIMS_INTEREST_HOLDER] ( [INTEREST_HOLDER_ID] bigint NOT NULL CONSTRAINT [INTHLD_INTEREST_HOLDER_ID_DEF] DEFAULT (NEXT VALUE FOR [PIMS_INTEREST_HOLDER_ID_SEQ]), + [ACQUISITION_FILE_ID] bigint NOT NULL, [PERSON_ID] bigint NULL, [ORGANIZATION_ID] bigint NULL, [IS_DISABLED] bit NULL CONSTRAINT [INTHLD_IS_DISABLED_DEF] DEFAULT (CONVERT([bit],(0))), @@ -235,7 +221,7 @@ GO PRINT N'Create table dbo.PIMS_INTHLDR_PROP_INTEREST' GO CREATE TABLE [dbo].[PIMS_INTHLDR_PROP_INTEREST] ( - [PIMS_INTHLDR_PROP_INTEREST_ID] varchar(40) NOT NULL CONSTRAINT [IHPRIN_PIMS_INTHLDR_PROP_INTEREST_ID_DEF] DEFAULT ('NEXT VALUE FOR [PIMS_INTHLDR_PROP_INTEREST_ID_SEQ]'), + [PIMS_INTHLDR_PROP_INTEREST_ID] bigint NOT NULL CONSTRAINT [IHPRIN_PIMS_INTHLDR_PROP_INTEREST_ID_DEF] DEFAULT (NEXT VALUE FOR [PIMS_INTHLDR_PROP_INTEREST_ID_SEQ]), [INTEREST_HOLDER_ID] bigint NOT NULL, [PROPERTY_ACQUISITION_FILE_ID] bigint NULL, [INTEREST_HOLDER_INTEREST_TYPE_CODE] nvarchar(20) NOT NULL, @@ -460,7 +446,8 @@ GO IF @@ERROR <> 0 SET NOEXEC ON GO ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE] - ADD [GST_NUMBER] nvarchar(50) NULL + ADD [GST_NUMBER] nvarchar(50) NULL, + [IS_PAYMENT_IN_TRUST] bit NULL CONSTRAINT [AQPCHQ_IS_PAYMENT_IN_TRUST_DEF] DEFAULT (CONVERT([bit],(0))) GO EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'GST number of the Payee' , @@ -480,7 +467,8 @@ GO PRINT N'Alter table dbo.PIMS_ACQ_PAYEE_CHEQUE_HIST' GO ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE_HIST] - ADD [GST_NUMBER] nvarchar(50) NULL + ADD [GST_NUMBER] nvarchar(50) NULL, + [IS_PAYMENT_IN_TRUST] bit NULL GO IF @@ERROR <> 0 SET NOEXEC ON GO @@ -513,6 +501,7 @@ CREATE TABLE [dbo].[PIMS_INTEREST_HOLDER_HIST] ( [EFFECTIVE_DATE_HIST] datetime NOT NULL DEFAULT (getutcdate()), [END_DATE_HIST] datetime NULL, [INTEREST_HOLDER_ID] bigint NOT NULL, + [ACQUISITION_FILE_ID] bigint NOT NULL, [PERSON_ID] bigint NULL, [ORGANIZATION_ID] bigint NULL, [IS_DISABLED] bit NULL, @@ -570,7 +559,7 @@ CREATE TABLE [dbo].[PIMS_INTHLDR_PROP_INTEREST_HIST] ( [_INTHLDR_PROP_INTEREST_HIST_ID] bigint NOT NULL DEFAULT (NEXT VALUE FOR [PIMS_INTHLDR_PROP_INTEREST_H_ID_SEQ]), [EFFECTIVE_DATE_HIST] datetime NOT NULL DEFAULT (getutcdate()), [END_DATE_HIST] datetime NULL, - [PIMS_INTHLDR_PROP_INTEREST_ID] varchar(40) NOT NULL, + [PIMS_INTHLDR_PROP_INTEREST_ID] bigint NOT NULL, [INTEREST_HOLDER_ID] bigint NOT NULL, [PROPERTY_ACQUISITION_FILE_ID] bigint NULL, [INTEREST_HOLDER_INTEREST_TYPE_CODE] nvarchar(20) NOT NULL, @@ -722,6 +711,19 @@ GO IF @@ERROR <> 0 SET NOEXEC ON GO +-- Create foreign key constraint dbo.PIM_ACQNFL_PIM_INTHLD_FK +PRINT N'Create foreign key constraint dbo.PIM_ACQNFL_PIM_INTHLD_FK' +GO +ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER] + ADD CONSTRAINT [PIM_ACQNFL_PIM_INTHLD_FK] + FOREIGN KEY([ACQUISITION_FILE_ID]) + REFERENCES [dbo].[PIMS_ACQUISITION_FILE]([ACQUISITION_FILE_ID]) + ON DELETE NO ACTION + ON UPDATE NO ACTION +GO +IF @@ERROR <> 0 SET NOEXEC ON +GO + -- Create foreign key constraint dbo.PIM_ORG_PIM_INTHLD_FK PRINT N'Create foreign key constraint dbo.PIM_ORG_PIM_INTHLD_FK' GO @@ -1055,6 +1057,7 @@ BEGIN TRY insert into PIMS_INTEREST_HOLDER ("INTEREST_HOLDER_ID", + "ACQUISITION_FILE_ID", "PERSON_ID", "ORGANIZATION_ID", "IS_DISABLED", @@ -1068,6 +1071,7 @@ BEGIN TRY "APP_LAST_UPDATE_USER_GUID", "APP_LAST_UPDATE_USER_DIRECTORY") select "INTEREST_HOLDER_ID", + "ACQUISITION_FILE_ID", "PERSON_ID", "ORGANIZATION_ID", "IS_DISABLED", @@ -1170,6 +1174,7 @@ BEGIN TRY "TAX_AMT" = inserted."TAX_AMT", "TOTAL_AMT" = inserted."TOTAL_AMT", "GST_NUMBER" = inserted."GST_NUMBER", + "IS_PAYMENT_IN_TRUST" = inserted."IS_PAYMENT_IN_TRUST", "CONCURRENCY_CONTROL_NUMBER" = inserted."CONCURRENCY_CONTROL_NUMBER", "APP_LAST_UPDATE_TIMESTAMP" = inserted."APP_LAST_UPDATE_TIMESTAMP", "APP_LAST_UPDATE_USERID" = inserted."APP_LAST_UPDATE_USERID", @@ -1207,8 +1212,8 @@ SET @curr_date = getutcdate(); update PIMS_ACQ_PAYEE_CHEQUE_HIST set END_DATE_HIST = @curr_date where ACQ_PAYEE_CHEQUE_ID in (select ACQ_PAYEE_CHEQUE_ID from deleted) and END_DATE_HIST is null; IF EXISTS(SELECT * FROM inserted) - insert into PIMS_ACQ_PAYEE_CHEQUE_HIST ([ACQ_PAYEE_CHEQUE_ID], [ACQUISITION_PAYEE_ID], [PRETAX_AMT], [TAX_AMT], [TOTAL_AMT], [GST_NUMBER], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _ACQ_PAYEE_CHEQUE_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST) - select [ACQ_PAYEE_CHEQUE_ID], [ACQUISITION_PAYEE_ID], [PRETAX_AMT], [TAX_AMT], [TOTAL_AMT], [GST_NUMBER], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_ACQ_PAYEE_CHEQUE_H_ID_SEQ]) as [_ACQ_PAYEE_CHEQUE_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted; + insert into PIMS_ACQ_PAYEE_CHEQUE_HIST ([ACQ_PAYEE_CHEQUE_ID], [ACQUISITION_PAYEE_ID], [PRETAX_AMT], [TAX_AMT], [TOTAL_AMT], [GST_NUMBER], [IS_PAYMENT_IN_TRUST], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _ACQ_PAYEE_CHEQUE_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST) + select [ACQ_PAYEE_CHEQUE_ID], [ACQUISITION_PAYEE_ID], [PRETAX_AMT], [TAX_AMT], [TOTAL_AMT], [GST_NUMBER], [IS_PAYMENT_IN_TRUST], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_ACQ_PAYEE_CHEQUE_H_ID_SEQ]) as [_ACQ_PAYEE_CHEQUE_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted; END TRY BEGIN CATCH @@ -1318,8 +1323,8 @@ SET @curr_date = getutcdate(); update PIMS_INTEREST_HOLDER_HIST set END_DATE_HIST = @curr_date where INTEREST_HOLDER_ID in (select INTEREST_HOLDER_ID from deleted) and END_DATE_HIST is null; IF EXISTS(SELECT * FROM inserted) - insert into PIMS_INTEREST_HOLDER_HIST ([INTEREST_HOLDER_ID], [PERSON_ID], [ORGANIZATION_ID], [IS_DISABLED], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _INTEREST_HOLDER_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST) - select [INTEREST_HOLDER_ID], [PERSON_ID], [ORGANIZATION_ID], [IS_DISABLED], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_INTEREST_HOLDER_H_ID_SEQ]) as [_INTEREST_HOLDER_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted; + insert into PIMS_INTEREST_HOLDER_HIST ([INTEREST_HOLDER_ID], [ACQUISITION_FILE_ID], [PERSON_ID], [ORGANIZATION_ID], [IS_DISABLED], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _INTEREST_HOLDER_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST) + select [INTEREST_HOLDER_ID], [ACQUISITION_FILE_ID], [PERSON_ID], [ORGANIZATION_ID], [IS_DISABLED], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_INTEREST_HOLDER_H_ID_SEQ]) as [_INTEREST_HOLDER_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted; END TRY BEGIN CATCH @@ -1347,6 +1352,7 @@ BEGIN TRY "TAX_AMT", "TOTAL_AMT", "GST_NUMBER", + "IS_PAYMENT_IN_TRUST", "CONCURRENCY_CONTROL_NUMBER", "APP_CREATE_TIMESTAMP", "APP_CREATE_USERID", @@ -1362,6 +1368,7 @@ BEGIN TRY "TAX_AMT", "TOTAL_AMT", "GST_NUMBER", + "IS_PAYMENT_IN_TRUST", "CONCURRENCY_CONTROL_NUMBER", "APP_CREATE_TIMESTAMP", "APP_CREATE_USERID", @@ -1479,6 +1486,7 @@ BEGIN TRY -- update statement update PIMS_INTEREST_HOLDER set "INTEREST_HOLDER_ID" = inserted."INTEREST_HOLDER_ID", + "ACQUISITION_FILE_ID" = inserted."ACQUISITION_FILE_ID", "PERSON_ID" = inserted."PERSON_ID", "ORGANIZATION_ID" = inserted."ORGANIZATION_ID", "IS_DISABLED" = inserted."IS_DISABLED", diff --git a/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Up/003_Delete_DynamicConstraint.sql b/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Up/003_Delete_DynamicConstraint.sql deleted file mode 100644 index aa8ee2306e..0000000000 --- a/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Up/003_Delete_DynamicConstraint.sql +++ /dev/null @@ -1,30 +0,0 @@ --- Drop dynamically-named default constraints -PRINT N'Drop dynamically-named default constraints' -GO -DECLARE @sqlQry VARCHAR(1000) -DECLARE @defName VARCHAR(100) -SET @defName = (SELECT obj.NAME - FROM SYSOBJECTS obj INNER JOIN - SYSCOLUMNS col on obj.ID = col.CDEFAULT INNER JOIN - SYSOBJECTS tbl on col.ID = tbl.ID - WHERE obj.XTYPE = 'D' - AND tbl.NAME = 'PIMS_COMP_REQ_H120' - AND col.NAME = 'FINANCIAL_ACTIVITY_CODE_ID') -SET @sqlQry = 'ALTER TABLE [dbo].[PIMS_COMP_REQ_H120] DROP CONSTRAINT IF EXISTS [' + @defName + ']' -EXEC (@sqlQry) -IF @@ERROR <> 0 SET NOEXEC ON -GO - -DECLARE @sqlQry VARCHAR(1000) -DECLARE @defName VARCHAR(100) -SET @defName = (SELECT obj.NAME - FROM SYSOBJECTS obj INNER JOIN - SYSCOLUMNS col on obj.ID = col.CDEFAULT INNER JOIN - SYSOBJECTS tbl on col.ID = tbl.ID - WHERE obj.XTYPE = 'D' - AND tbl.NAME = 'PIMS_COMP_REQ_H120_HIST' - AND col.NAME = 'FINANCIAL_ACTIVITY_CODE_ID') -SET @sqlQry = 'ALTER TABLE [dbo].[PIMS_COMP_REQ_H120] DROP CONSTRAINT IF EXISTS [' + @defName + ']' -EXEC (@sqlQry) -IF @@ERROR <> 0 SET NOEXEC ON -GO diff --git a/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Up/007_Add_Aquisiton_File_FK.sql b/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Up/007_Add_Aquisiton_File_FK.sql deleted file mode 100644 index 571ca50fe0..0000000000 --- a/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Up/007_Add_Aquisiton_File_FK.sql +++ /dev/null @@ -1,15 +0,0 @@ -/* ----------------------------------------------------------------------------- -Add foreign key from PIMS_ACQUISITION_FILE to PIMS_INTEREST_HOLDER. -. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -Author Date Comment ------------- ----------- ----------------------------------------------------- -Doug Filteau 2023-May-29 Initial version ------------------------------------------------------------------------------ */ - -ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER] - ADD [ACQUISITION_FILE_ID] BIGINT NOT NULL -GO - -ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER] ADD CONSTRAINT [PIM_ACQNFL_PIM_INTHLD_FK] - FOREIGN KEY ([ACQUISITION_FILE_ID]) REFERENCES [dbo].[PIMS_ACQUISITION_FILE] ([ACQUISITION_FILE_ID]) -GO diff --git a/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Up/Schema Compare.zip b/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Up/Schema Compare.zip index 6027289c15..e63e12611e 100644 Binary files a/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Up/Schema Compare.zip and b/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Alter Up/Schema Compare.zip differ diff --git a/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Build/002_PSP_PIMS_Build.sql b/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Build/002_PSP_PIMS_Build.sql index 4196e3d362..356fa0417c 100644 --- a/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Build/002_PSP_PIMS_Build.sql +++ b/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Build/002_PSP_PIMS_Build.sql @@ -1,5 +1,5 @@ /* -Script generated by Aqua Data Studio 22.2.0 on May-26-2023 11:44:32 a.m. +Script generated by Aqua Data Studio 22.2.0 on May-30-2023 01:59:14 p.m. Database: PIMS_PSP_S55_00 Schema: dbo Objects: DATATYPE, DEFAULT, RULE, SEQUENCE, TABLE, VIEW, SYNONYM, PROCEDURE, FUNCTION, INDEX, TRIGGER, DATABASETRIGGER, DATABASE_AUDIT_SPEC @@ -224,16 +224,6 @@ CREATE SEQUENCE [dbo].[PIMS_ACQUISITION_FILE_PERSON_ID_SEQ] CACHE 50 GO ---CREATE SEQUENCE [dbo].[PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ] --- AS bigint --- START WITH 1 --- INCREMENT BY 1 --- MINVALUE 1 --- MAXVALUE 2147483647 --- NO CYCLE --- CACHE 50 ---GO - CREATE SEQUENCE [dbo].[PIMS_ACQUISITION_OWNER_H_ID_SEQ] AS bigint START WITH 1 @@ -4891,6 +4881,7 @@ GO CREATE TABLE [dbo].[PIMS_INTEREST_HOLDER] ( [INTEREST_HOLDER_ID] bigint NOT NULL CONSTRAINT [INTHLD_INTEREST_HOLDER_ID_DEF] DEFAULT (NEXT VALUE FOR [PIMS_INTEREST_HOLDER_ID_SEQ]), + [ACQUISITION_FILE_ID] bigint NOT NULL, [PERSON_ID] bigint NULL, [ORGANIZATION_ID] bigint NULL, [IS_DISABLED] bit NULL CONSTRAINT [INTHLD_IS_DISABLED_DEF] DEFAULT (CONVERT([bit],(0))), @@ -4995,6 +4986,7 @@ CREATE TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE] ( [TAX_AMT] money NULL, [TOTAL_AMT] money NULL, [GST_NUMBER] nvarchar(50) NULL, + [IS_PAYMENT_IN_TRUST] bit NULL CONSTRAINT [AQPCHQ_IS_PAYMENT_IN_TRUST_DEF] DEFAULT (CONVERT([bit],(0))), [CONCURRENCY_CONTROL_NUMBER] bigint NOT NULL CONSTRAINT [AQPCHQ_CONCURRENCY_CONTROL_NUMBER_DEF] DEFAULT ((1)), [APP_CREATE_TIMESTAMP] datetime NOT NULL CONSTRAINT [AQPCHQ_APP_CREATE_TIMESTAMP_DEF] DEFAULT (getutcdate()), [APP_CREATE_USERID] nvarchar(30) NOT NULL CONSTRAINT [AQPCHQ_APP_CREATE_USERID_DEF] DEFAULT (user_name()), @@ -5051,6 +5043,7 @@ CREATE TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE_HIST] ( [TAX_AMT] money NULL, [TOTAL_AMT] money NULL, [GST_NUMBER] nvarchar(50) NULL, + [IS_PAYMENT_IN_TRUST] bit NULL, [CONCURRENCY_CONTROL_NUMBER] bigint NOT NULL, [APP_CREATE_TIMESTAMP] datetime NOT NULL, [APP_CREATE_USERID] nvarchar(30) NOT NULL, @@ -7870,6 +7863,7 @@ CREATE TABLE [dbo].[PIMS_INTEREST_HOLDER_HIST] ( [EFFECTIVE_DATE_HIST] datetime NOT NULL DEFAULT (getutcdate()), [END_DATE_HIST] datetime NULL, [INTEREST_HOLDER_ID] bigint NOT NULL, + [ACQUISITION_FILE_ID] bigint NOT NULL, [PERSON_ID] bigint NULL, [ORGANIZATION_ID] bigint NULL, [IS_DISABLED] bit NULL, @@ -7934,7 +7928,7 @@ EXEC sp_addextendedproperty GO CREATE TABLE [dbo].[PIMS_INTHLDR_PROP_INTEREST] ( - [PIMS_INTHLDR_PROP_INTEREST_ID] varchar(40) NOT NULL CONSTRAINT [IHPRIN_PIMS_INTHLDR_PROP_INTEREST_ID_DEF] DEFAULT ('NEXT VALUE FOR [PIMS_INTHLDR_PROP_INTEREST_ID_SEQ]'), + [PIMS_INTHLDR_PROP_INTEREST_ID] bigint NOT NULL CONSTRAINT [IHPRIN_PIMS_INTHLDR_PROP_INTEREST_ID_DEF] DEFAULT (NEXT VALUE FOR [PIMS_INTHLDR_PROP_INTEREST_ID_SEQ]), [INTEREST_HOLDER_ID] bigint NOT NULL, [PROPERTY_ACQUISITION_FILE_ID] bigint NULL, [INTEREST_HOLDER_INTEREST_TYPE_CODE] nvarchar(20) NOT NULL, @@ -7966,7 +7960,7 @@ CREATE TABLE [dbo].[PIMS_INTHLDR_PROP_INTEREST_HIST] ( [_INTHLDR_PROP_INTEREST_HIST_ID] bigint NOT NULL DEFAULT (NEXT VALUE FOR [PIMS_INTHLDR_PROP_INTEREST_H_ID_SEQ]), [EFFECTIVE_DATE_HIST] datetime NOT NULL DEFAULT (getutcdate()), [END_DATE_HIST] datetime NULL, - [PIMS_INTHLDR_PROP_INTEREST_ID] varchar(40) NOT NULL, + [PIMS_INTHLDR_PROP_INTEREST_ID] bigint NOT NULL, [INTEREST_HOLDER_ID] bigint NOT NULL, [PROPERTY_ACQUISITION_FILE_ID] bigint NULL, [INTEREST_HOLDER_INTEREST_TYPE_CODE] nvarchar(20) NOT NULL, @@ -11884,6 +11878,7 @@ WITH AND CON.RN = 1 GO + CREATE VIEW [dbo].[PIMS_PROPERTY_BOUNDARY_VW] AS SELECT PROP.PROPERTY_ID , PROP.PID @@ -13031,106 +13026,6 @@ CREATE NONCLUSTERED INDEX [YRFINC_CODE_IDX] ON [dbo].[PIMS_YEARLY_FINANCIAL_CODE]([CODE]) GO -CREATE TRIGGER [dbo].[PIMS_CLMTYP_I_S_I_TR] ON PIMS_CLAIM INSTEAD OF INSERT AS -SET NOCOUNT ON -BEGIN TRY - IF NOT EXISTS(SELECT * FROM inserted) - RETURN; - - - insert into PIMS_CLAIM ("CLAIM_ID", - "CLAIM_UID", - "KEYCLOAK_ROLE_ID", - "NAME", - "DESCRIPTION", - "IS_DISABLED", - "CONCURRENCY_CONTROL_NUMBER", - "APP_CREATE_TIMESTAMP", - "APP_CREATE_USERID", - "APP_CREATE_USER_GUID", - "APP_CREATE_USER_DIRECTORY", - "APP_LAST_UPDATE_TIMESTAMP", - "APP_LAST_UPDATE_USERID", - "APP_LAST_UPDATE_USER_GUID", - "APP_LAST_UPDATE_USER_DIRECTORY") - select "CLAIM_ID", - "CLAIM_UID", - "KEYCLOAK_ROLE_ID", - "NAME", - "DESCRIPTION", - "IS_DISABLED", - "CONCURRENCY_CONTROL_NUMBER", - "APP_CREATE_TIMESTAMP", - "APP_CREATE_USERID", - "APP_CREATE_USER_GUID", - "APP_CREATE_USER_DIRECTORY", - "APP_LAST_UPDATE_TIMESTAMP", - "APP_LAST_UPDATE_USERID", - "APP_LAST_UPDATE_USER_GUID", - "APP_LAST_UPDATE_USER_DIRECTORY" - from inserted; - -END TRY -BEGIN CATCH - IF @@trancount > 0 ROLLBACK TRANSACTION - EXEC pims_error_handling -END CATCH; -GO - -CREATE TRIGGER [dbo].[PIMS_LELIST_I_S_U_TR] ON PIMS_LEASE_LICENSE_TYPE INSTEAD OF UPDATE AS -SET NOCOUNT ON -BEGIN TRY - IF NOT EXISTS(SELECT * FROM deleted) - RETURN; - - -- validate concurrency control - if exists (select 1 from inserted, deleted where inserted.CONCURRENCY_CONTROL_NUMBER != deleted.CONCURRENCY_CONTROL_NUMBER+1 AND inserted.LEASE_LICENSE_TYPE_CODE = deleted.LEASE_LICENSE_TYPE_CODE) - raiserror('CONCURRENCY FAILURE.',16,1) - - - -- update statement - update PIMS_LEASE_LICENSE_TYPE - set "LEASE_LICENSE_TYPE_CODE" = inserted."LEASE_LICENSE_TYPE_CODE", - "DESCRIPTION" = inserted."DESCRIPTION", - "IS_DISABLED" = inserted."IS_DISABLED", - "DISPLAY_ORDER" = inserted."DISPLAY_ORDER", - "CONCURRENCY_CONTROL_NUMBER" = inserted."CONCURRENCY_CONTROL_NUMBER" - , DB_LAST_UPDATE_TIMESTAMP = getutcdate() - , DB_LAST_UPDATE_USERID = user_name() - from PIMS_LEASE_LICENSE_TYPE - inner join inserted - on (PIMS_LEASE_LICENSE_TYPE.LEASE_LICENSE_TYPE_CODE = inserted.LEASE_LICENSE_TYPE_CODE); - -END TRY -BEGIN CATCH - IF @@trancount > 0 ROLLBACK TRANSACTION - EXEC pims_error_handling -END CATCH; -GO - -CREATE TRIGGER [dbo].[PIMS_CNTMTH_A_S_IUD_TR] ON PIMS_CONTACT_METHOD FOR INSERT, UPDATE, DELETE AS -SET NOCOUNT ON -BEGIN TRY -DECLARE @curr_date datetime; -SET @curr_date = getutcdate(); - IF NOT EXISTS(SELECT * FROM inserted) AND NOT EXISTS(SELECT * FROM deleted) - RETURN; - - -- historical - IF EXISTS(SELECT * FROM deleted) - update PIMS_CONTACT_METHOD_HIST set END_DATE_HIST = @curr_date where CONTACT_METHOD_ID in (select CONTACT_METHOD_ID from deleted) and END_DATE_HIST is null; - - IF EXISTS(SELECT * FROM inserted) - insert into PIMS_CONTACT_METHOD_HIST ([CONTACT_METHOD_ID], [CONTACT_METHOD_TYPE_CODE], [PERSON_ID], [ORGANIZATION_ID], [CONTACT_METHOD_VALUE], [IS_PREFERRED_METHOD], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _CONTACT_METHOD_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST) - select [CONTACT_METHOD_ID], [CONTACT_METHOD_TYPE_CODE], [PERSON_ID], [ORGANIZATION_ID], [CONTACT_METHOD_VALUE], [IS_PREFERRED_METHOD], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_CONTACT_METHOD_H_ID_SEQ]) as [_CONTACT_METHOD_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted; - -END TRY -BEGIN CATCH - IF @@trancount > 0 ROLLBACK TRANSACTION - EXEC pims_error_handling -END CATCH; -GO - CREATE TRIGGER [dbo].[PIMS_CRH120_I_S_I_TR] ON PIMS_COMP_REQ_H120 INSTEAD OF INSERT AS SET NOCOUNT ON BEGIN TRY @@ -13957,8 +13852,8 @@ SET @curr_date = getutcdate(); update PIMS_INTEREST_HOLDER_HIST set END_DATE_HIST = @curr_date where INTEREST_HOLDER_ID in (select INTEREST_HOLDER_ID from deleted) and END_DATE_HIST is null; IF EXISTS(SELECT * FROM inserted) - insert into PIMS_INTEREST_HOLDER_HIST ([INTEREST_HOLDER_ID], [PERSON_ID], [ORGANIZATION_ID], [IS_DISABLED], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _INTEREST_HOLDER_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST) - select [INTEREST_HOLDER_ID], [PERSON_ID], [ORGANIZATION_ID], [IS_DISABLED], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_INTEREST_HOLDER_H_ID_SEQ]) as [_INTEREST_HOLDER_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted; + insert into PIMS_INTEREST_HOLDER_HIST ([INTEREST_HOLDER_ID], [ACQUISITION_FILE_ID], [PERSON_ID], [ORGANIZATION_ID], [IS_DISABLED], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _INTEREST_HOLDER_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST) + select [INTEREST_HOLDER_ID], [ACQUISITION_FILE_ID], [PERSON_ID], [ORGANIZATION_ID], [IS_DISABLED], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_INTEREST_HOLDER_H_ID_SEQ]) as [_INTEREST_HOLDER_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted; END TRY BEGIN CATCH @@ -15187,6 +15082,7 @@ BEGIN TRY insert into PIMS_INTEREST_HOLDER ("INTEREST_HOLDER_ID", + "ACQUISITION_FILE_ID", "PERSON_ID", "ORGANIZATION_ID", "IS_DISABLED", @@ -15200,6 +15096,7 @@ BEGIN TRY "APP_LAST_UPDATE_USER_GUID", "APP_LAST_UPDATE_USER_DIRECTORY") select "INTEREST_HOLDER_ID", + "ACQUISITION_FILE_ID", "PERSON_ID", "ORGANIZATION_ID", "IS_DISABLED", @@ -19636,6 +19533,7 @@ BEGIN TRY "TAX_AMT" = inserted."TAX_AMT", "TOTAL_AMT" = inserted."TOTAL_AMT", "GST_NUMBER" = inserted."GST_NUMBER", + "IS_PAYMENT_IN_TRUST" = inserted."IS_PAYMENT_IN_TRUST", "CONCURRENCY_CONTROL_NUMBER" = inserted."CONCURRENCY_CONTROL_NUMBER", "APP_LAST_UPDATE_TIMESTAMP" = inserted."APP_LAST_UPDATE_TIMESTAMP", "APP_LAST_UPDATE_USERID" = inserted."APP_LAST_UPDATE_USERID", @@ -23302,6 +23200,7 @@ BEGIN TRY "TAX_AMT", "TOTAL_AMT", "GST_NUMBER", + "IS_PAYMENT_IN_TRUST", "CONCURRENCY_CONTROL_NUMBER", "APP_CREATE_TIMESTAMP", "APP_CREATE_USERID", @@ -23317,6 +23216,7 @@ BEGIN TRY "TAX_AMT", "TOTAL_AMT", "GST_NUMBER", + "IS_PAYMENT_IN_TRUST", "CONCURRENCY_CONTROL_NUMBER", "APP_CREATE_TIMESTAMP", "APP_CREATE_USERID", @@ -26100,6 +26000,7 @@ BEGIN TRY -- update statement update PIMS_INTEREST_HOLDER set "INTEREST_HOLDER_ID" = inserted."INTEREST_HOLDER_ID", + "ACQUISITION_FILE_ID" = inserted."ACQUISITION_FILE_ID", "PERSON_ID" = inserted."PERSON_ID", "ORGANIZATION_ID" = inserted."ORGANIZATION_ID", "IS_DISABLED" = inserted."IS_DISABLED", @@ -26938,8 +26839,8 @@ SET @curr_date = getutcdate(); update PIMS_ACQ_PAYEE_CHEQUE_HIST set END_DATE_HIST = @curr_date where ACQ_PAYEE_CHEQUE_ID in (select ACQ_PAYEE_CHEQUE_ID from deleted) and END_DATE_HIST is null; IF EXISTS(SELECT * FROM inserted) - insert into PIMS_ACQ_PAYEE_CHEQUE_HIST ([ACQ_PAYEE_CHEQUE_ID], [ACQUISITION_PAYEE_ID], [PRETAX_AMT], [TAX_AMT], [TOTAL_AMT], [GST_NUMBER], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _ACQ_PAYEE_CHEQUE_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST) - select [ACQ_PAYEE_CHEQUE_ID], [ACQUISITION_PAYEE_ID], [PRETAX_AMT], [TAX_AMT], [TOTAL_AMT], [GST_NUMBER], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_ACQ_PAYEE_CHEQUE_H_ID_SEQ]) as [_ACQ_PAYEE_CHEQUE_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted; + insert into PIMS_ACQ_PAYEE_CHEQUE_HIST ([ACQ_PAYEE_CHEQUE_ID], [ACQUISITION_PAYEE_ID], [PRETAX_AMT], [TAX_AMT], [TOTAL_AMT], [GST_NUMBER], [IS_PAYMENT_IN_TRUST], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _ACQ_PAYEE_CHEQUE_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST) + select [ACQ_PAYEE_CHEQUE_ID], [ACQUISITION_PAYEE_ID], [PRETAX_AMT], [TAX_AMT], [TOTAL_AMT], [GST_NUMBER], [IS_PAYMENT_IN_TRUST], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_ACQ_PAYEE_CHEQUE_H_ID_SEQ]) as [_ACQ_PAYEE_CHEQUE_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted; END TRY BEGIN CATCH @@ -27318,6 +27219,106 @@ BEGIN CATCH END CATCH; GO +CREATE TRIGGER [dbo].[PIMS_CLMTYP_I_S_I_TR] ON PIMS_CLAIM INSTEAD OF INSERT AS +SET NOCOUNT ON +BEGIN TRY + IF NOT EXISTS(SELECT * FROM inserted) + RETURN; + + + insert into PIMS_CLAIM ("CLAIM_ID", + "CLAIM_UID", + "KEYCLOAK_ROLE_ID", + "NAME", + "DESCRIPTION", + "IS_DISABLED", + "CONCURRENCY_CONTROL_NUMBER", + "APP_CREATE_TIMESTAMP", + "APP_CREATE_USERID", + "APP_CREATE_USER_GUID", + "APP_CREATE_USER_DIRECTORY", + "APP_LAST_UPDATE_TIMESTAMP", + "APP_LAST_UPDATE_USERID", + "APP_LAST_UPDATE_USER_GUID", + "APP_LAST_UPDATE_USER_DIRECTORY") + select "CLAIM_ID", + "CLAIM_UID", + "KEYCLOAK_ROLE_ID", + "NAME", + "DESCRIPTION", + "IS_DISABLED", + "CONCURRENCY_CONTROL_NUMBER", + "APP_CREATE_TIMESTAMP", + "APP_CREATE_USERID", + "APP_CREATE_USER_GUID", + "APP_CREATE_USER_DIRECTORY", + "APP_LAST_UPDATE_TIMESTAMP", + "APP_LAST_UPDATE_USERID", + "APP_LAST_UPDATE_USER_GUID", + "APP_LAST_UPDATE_USER_DIRECTORY" + from inserted; + +END TRY +BEGIN CATCH + IF @@trancount > 0 ROLLBACK TRANSACTION + EXEC pims_error_handling +END CATCH; +GO + +CREATE TRIGGER [dbo].[PIMS_LELIST_I_S_U_TR] ON PIMS_LEASE_LICENSE_TYPE INSTEAD OF UPDATE AS +SET NOCOUNT ON +BEGIN TRY + IF NOT EXISTS(SELECT * FROM deleted) + RETURN; + + -- validate concurrency control + if exists (select 1 from inserted, deleted where inserted.CONCURRENCY_CONTROL_NUMBER != deleted.CONCURRENCY_CONTROL_NUMBER+1 AND inserted.LEASE_LICENSE_TYPE_CODE = deleted.LEASE_LICENSE_TYPE_CODE) + raiserror('CONCURRENCY FAILURE.',16,1) + + + -- update statement + update PIMS_LEASE_LICENSE_TYPE + set "LEASE_LICENSE_TYPE_CODE" = inserted."LEASE_LICENSE_TYPE_CODE", + "DESCRIPTION" = inserted."DESCRIPTION", + "IS_DISABLED" = inserted."IS_DISABLED", + "DISPLAY_ORDER" = inserted."DISPLAY_ORDER", + "CONCURRENCY_CONTROL_NUMBER" = inserted."CONCURRENCY_CONTROL_NUMBER" + , DB_LAST_UPDATE_TIMESTAMP = getutcdate() + , DB_LAST_UPDATE_USERID = user_name() + from PIMS_LEASE_LICENSE_TYPE + inner join inserted + on (PIMS_LEASE_LICENSE_TYPE.LEASE_LICENSE_TYPE_CODE = inserted.LEASE_LICENSE_TYPE_CODE); + +END TRY +BEGIN CATCH + IF @@trancount > 0 ROLLBACK TRANSACTION + EXEC pims_error_handling +END CATCH; +GO + +CREATE TRIGGER [dbo].[PIMS_CNTMTH_A_S_IUD_TR] ON PIMS_CONTACT_METHOD FOR INSERT, UPDATE, DELETE AS +SET NOCOUNT ON +BEGIN TRY +DECLARE @curr_date datetime; +SET @curr_date = getutcdate(); + IF NOT EXISTS(SELECT * FROM inserted) AND NOT EXISTS(SELECT * FROM deleted) + RETURN; + + -- historical + IF EXISTS(SELECT * FROM deleted) + update PIMS_CONTACT_METHOD_HIST set END_DATE_HIST = @curr_date where CONTACT_METHOD_ID in (select CONTACT_METHOD_ID from deleted) and END_DATE_HIST is null; + + IF EXISTS(SELECT * FROM inserted) + insert into PIMS_CONTACT_METHOD_HIST ([CONTACT_METHOD_ID], [CONTACT_METHOD_TYPE_CODE], [PERSON_ID], [ORGANIZATION_ID], [CONTACT_METHOD_VALUE], [IS_PREFERRED_METHOD], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _CONTACT_METHOD_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST) + select [CONTACT_METHOD_ID], [CONTACT_METHOD_TYPE_CODE], [PERSON_ID], [ORGANIZATION_ID], [CONTACT_METHOD_VALUE], [IS_PREFERRED_METHOD], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_CONTACT_METHOD_H_ID_SEQ]) as [_CONTACT_METHOD_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted; + +END TRY +BEGIN CATCH + IF @@trancount > 0 ROLLBACK TRANSACTION + EXEC pims_error_handling +END CATCH; +GO + ALTER TABLE [dbo].[PIMS_ACCESS_REQUEST] ADD CONSTRAINT [ACRQST_USER_ROLE_REGION_TUC] @@ -28959,6 +28960,14 @@ ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER] ON UPDATE NO ACTION GO +ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER] + ADD CONSTRAINT [PIM_ACQNFL_PIM_INTHLD_FK] + FOREIGN KEY([ACQUISITION_FILE_ID]) + REFERENCES [dbo].[PIMS_ACQUISITION_FILE]([ACQUISITION_FILE_ID]) + ON DELETE NO ACTION + ON UPDATE NO ACTION +GO + ALTER TABLE [dbo].[PIMS_ACQUISITION_PAYEE] ADD CONSTRAINT [PIM_INTHLD_PIM_ACQPAY_FK] FOREIGN KEY([INTEREST_HOLDER_ID]) diff --git a/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Build/007_Add_Aquisiton_File_FK.sql b/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Build/007_Add_Aquisiton_File_FK.sql deleted file mode 100644 index 571ca50fe0..0000000000 --- a/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Build/007_Add_Aquisiton_File_FK.sql +++ /dev/null @@ -1,15 +0,0 @@ -/* ----------------------------------------------------------------------------- -Add foreign key from PIMS_ACQUISITION_FILE to PIMS_INTEREST_HOLDER. -. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -Author Date Comment ------------- ----------- ----------------------------------------------------- -Doug Filteau 2023-May-29 Initial version ------------------------------------------------------------------------------ */ - -ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER] - ADD [ACQUISITION_FILE_ID] BIGINT NOT NULL -GO - -ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER] ADD CONSTRAINT [PIM_ACQNFL_PIM_INTHLD_FK] - FOREIGN KEY ([ACQUISITION_FILE_ID]) REFERENCES [dbo].[PIMS_ACQUISITION_FILE] ([ACQUISITION_FILE_ID]) -GO diff --git a/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Drop/01_PSP_PIMS_Drop.sql b/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Drop/01_PSP_PIMS_Drop.sql index c8d77b852d..e15cdf3473 100644 --- a/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Drop/01_PSP_PIMS_Drop.sql +++ b/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/Drop/01_PSP_PIMS_Drop.sql @@ -5,7 +5,7 @@ /* Project name: MoTI Property Services Project */ /* Author: Doug Filteau */ /* Script type: Database drop script */ -/* Created on: 2023-05-26 11:18 */ +/* Created on: 2023-05-30 13:44 */ /* ---------------------------------------------------------------------- */ @@ -2521,6 +2521,10 @@ ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER] DROP CONSTRAINT [PIM_ORG_PIM_INTHLD_FK] GO +ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER] DROP CONSTRAINT [PIM_ACQNFL_PIM_INTHLD_FK] +GO + + ALTER TABLE [dbo].[PIMS_ACQUISITION_OWNER_REP] DROP CONSTRAINT [PIM_ACQNFL_PIM_AQOWRP_FK] GO @@ -3151,6 +3155,10 @@ ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE] DROP CONSTRAINT [AQPCHQ_ACQ_PAYEE_CHEQ GO +ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE] DROP CONSTRAINT [AQPCHQ_IS_PAYMENT_IN_TRUST_DEF] +GO + + ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE] DROP CONSTRAINT [AQPCHQ_CONCURRENCY_CONTROL_NUMBER_DEF] GO @@ -14623,10 +14631,6 @@ DROP SEQUENCE [dbo].[PIMS_INTEREST_HOLDER_PROPERTY_ID_SEQ] GO -DROP SEQUENCE [dbo].[PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ] -GO - - DROP SEQUENCE [dbo].[PIMS_OWNER_REPRESENTATIVE_ID_SEQ] GO diff --git a/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/PIMS PDM S55.00.png b/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/PIMS PDM S55.00.png index 6c545215a2..950ea797cb 100644 Binary files a/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/PIMS PDM S55.00.png and b/source/database/mssql/scripts/dbscripts/PSP_PIMS_LATEST/PIMS PDM S55.00.png differ diff --git a/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Alter Down/01_PSP_PIMS_Alter_Down.sql b/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Alter Down/01_PSP_PIMS_Alter_Down.sql index 51c6ebb94f..3d3dcbee78 100644 --- a/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Alter Down/01_PSP_PIMS_Alter_Down.sql +++ b/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Alter Down/01_PSP_PIMS_Alter_Down.sql @@ -1,4 +1,4 @@ --- Script generated by Aqua Data Studio Schema Synchronization for MS SQL Server 2016 on Fri May 26 13:07:41 PDT 2023 +-- Script generated by Aqua Data Studio Schema Synchronization for MS SQL Server 2016 on Tue May 30 16:17:33 PDT 2023 -- Execute this script on: -- PIMS_PSP_S55_00/dbo - This database/schema will be modified -- to synchronize it with MS SQL Server 2016: @@ -138,6 +138,15 @@ GO IF @@ERROR <> 0 SET NOEXEC ON GO +-- Drop foreign key constraint dbo.PIM_ACQNFL_PIM_INTHLD_FK +PRINT N'Drop foreign key constraint dbo.PIM_ACQNFL_PIM_INTHLD_FK' +GO +ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER] + DROP CONSTRAINT IF EXISTS [PIM_ACQNFL_PIM_INTHLD_FK] +GO +IF @@ERROR <> 0 SET NOEXEC ON +GO + -- Drop index dbo.IHPRIN_PROPERTY_ACQUISITION_FILE_ID_IDX PRINT N'Drop index dbo.IHPRIN_PROPERTY_ACQUISITION_FILE_ID_IDX' GO @@ -521,29 +530,13 @@ GO IF @@ERROR <> 0 SET NOEXEC ON GO --- Drop sequence dbo.PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ -PRINT N'Drop sequence dbo.PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ' -GO -DROP SEQUENCE IF EXISTS [dbo].[PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ] -GO -IF @@ERROR <> 0 SET NOEXEC ON -GO - -- Alter table dbo.PIMS_ACQUISITION_PAYEE PRINT N'Alter table dbo.PIMS_ACQUISITION_PAYEE' GO ---UPDATE [dbo].[PIMS_ACQUISITION_PAYEE] SET [ACQUISITION_OWNER_ID] = -1 WHERE [ACQUISITION_OWNER_ID] IS NULL ---GO ---IF @@ERROR <> 0 SET NOEXEC ON ---GO ALTER TABLE [dbo].[PIMS_ACQUISITION_PAYEE] ALTER COLUMN [ACQUISITION_OWNER_ID] bigint NOT NULL GO IF @@ERROR <> 0 SET NOEXEC ON GO ---ALTER TABLE [dbo].[PIMS_ACQUISITION_PAYEE] ADD DEFAULT -1 FOR [ACQUISITION_OWNER_ID] ---GO ---IF @@ERROR <> 0 SET NOEXEC ON ---GO ALTER TABLE [dbo].[PIMS_ACQUISITION_PAYEE] DROP COLUMN IF EXISTS [INTEREST_HOLDER_ID], [OWNER_REPRESENTATIVE_ID], [OWNER_SOLICITOR_ID], [ACQUISITION_FILE_PERSON_ID] GO @@ -553,18 +546,10 @@ GO -- Alter table dbo.PIMS_ACQUISITION_PAYEE_HIST PRINT N'Alter table dbo.PIMS_ACQUISITION_PAYEE_HIST' GO ---UPDATE [dbo].[PIMS_ACQUISITION_PAYEE_HIST] SET [ACQUISITION_OWNER_ID] = -1 WHERE [ACQUISITION_OWNER_ID] IS NULL ---GO ---IF @@ERROR <> 0 SET NOEXEC ON ---GO ALTER TABLE [dbo].[PIMS_ACQUISITION_PAYEE_HIST] ALTER COLUMN [ACQUISITION_OWNER_ID] bigint NOT NULL GO IF @@ERROR <> 0 SET NOEXEC ON GO ---ALTER TABLE [dbo].[PIMS_ACQUISITION_PAYEE_HIST] ADD DEFAULT -1 FOR [ACQUISITION_OWNER_ID] ---GO ---IF @@ERROR <> 0 SET NOEXEC ON ---GO ALTER TABLE [dbo].[PIMS_ACQUISITION_PAYEE_HIST] DROP COLUMN IF EXISTS [INTEREST_HOLDER_ID], [OWNER_REPRESENTATIVE_ID], [OWNER_SOLICITOR_ID], [ACQUISITION_FILE_PERSON_ID] GO @@ -574,6 +559,11 @@ GO -- Alter table dbo.PIMS_ACQ_PAYEE_CHEQUE PRINT N'Alter table dbo.PIMS_ACQ_PAYEE_CHEQUE' GO +ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE] + DROP CONSTRAINT IF EXISTS [AQPCHQ_IS_PAYMENT_IN_TRUST_DEF] +GO +IF @@ERROR <> 0 SET NOEXEC ON +GO ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE] ADD [IS_GST_REQUIRED] bit NULL CONSTRAINT [AQPCHQ_IS_GST_REQUIRED_DEF] DEFAULT (CONVERT([bit],(0))) GO @@ -586,7 +576,7 @@ GO IF @@ERROR <> 0 SET NOEXEC ON GO ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE] - DROP COLUMN IF EXISTS [GST_NUMBER] + DROP COLUMN IF EXISTS [GST_NUMBER], [IS_PAYMENT_IN_TRUST] GO IF @@ERROR <> 0 SET NOEXEC ON GO @@ -600,7 +590,7 @@ GO IF @@ERROR <> 0 SET NOEXEC ON GO ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE_HIST] - DROP COLUMN IF EXISTS [GST_NUMBER] + DROP COLUMN IF EXISTS [GST_NUMBER], [IS_PAYMENT_IN_TRUST] GO IF @@ERROR <> 0 SET NOEXEC ON GO @@ -612,10 +602,6 @@ ALTER TABLE [dbo].[PIMS_ACQ_CHKLST_SECTION_TYPE] DROP CONSTRAINT IF EXISTS [AQCS GO IF @@ERROR <> 0 SET NOEXEC ON GO ---ALTER TABLE [dbo].[PIMS_ACQ_CHKLST_SECTION_TYPE] ADD DEFAULT getutcdate() FOR [EFFECTIVE_DATE] ---GO ---IF @@ERROR <> 0 SET NOEXEC ON ---GO -- Alter table dbo.PIMS_ACQ_CHKLST_ITEM_TYPE PRINT N'Alter table dbo.PIMS_ACQ_CHKLST_ITEM_TYPE' @@ -624,10 +610,6 @@ ALTER TABLE [dbo].[PIMS_ACQ_CHKLST_ITEM_TYPE] DROP CONSTRAINT IF EXISTS [ACQCIT_ GO IF @@ERROR <> 0 SET NOEXEC ON GO ---ALTER TABLE [dbo].[PIMS_ACQ_CHKLST_ITEM_TYPE] ADD DEFAULT getutcdate() FOR [EFFECTIVE_DATE] ---GO ---IF @@ERROR <> 0 SET NOEXEC ON ---GO -- Create index dbo.ACQPAY_ACQUISITION_OWNER_ID_IDX PRINT N'Create index dbo.ACQPAY_ACQUISITION_OWNER_ID_IDX' diff --git a/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Alter Up/002_PSP_PIMS_Alter_Up.sql b/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Alter Up/002_PSP_PIMS_Alter_Up.sql index 9f14b45226..8fcce05d97 100644 --- a/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Alter Up/002_PSP_PIMS_Alter_Up.sql +++ b/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Alter Up/002_PSP_PIMS_Alter_Up.sql @@ -1,4 +1,4 @@ --- Script generated by Aqua Data Studio Schema Synchronization for MS SQL Server 2016 on Fri May 26 13:03:56 PDT 2023 +-- Script generated by Aqua Data Studio Schema Synchronization for MS SQL Server 2016 on Tue May 30 16:14:09 PDT 2023 -- Execute this script on: -- PIMS_PSP_S54_00/dbo - This database/schema will be modified -- to synchronize it with MS SQL Server 2016: @@ -63,21 +63,6 @@ GO IF @@ERROR <> 0 SET NOEXEC ON GO ----- Create sequence dbo.PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ ---PRINT N'Create sequence dbo.PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ' ---GO ---CREATE SEQUENCE [dbo].[PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ] --- AS bigint --- START WITH 1 --- INCREMENT BY 1 --- MINVALUE 1 --- MAXVALUE 2147483647 --- NO CYCLE --- CACHE 50 ---GO ---IF @@ERROR <> 0 SET NOEXEC ON ---GO - -- Create sequence dbo.PIMS_INTHLDR_PROP_INTEREST_ID_SEQ PRINT N'Create sequence dbo.PIMS_INTHLDR_PROP_INTEREST_ID_SEQ' GO @@ -128,6 +113,7 @@ PRINT N'Create table dbo.PIMS_INTEREST_HOLDER' GO CREATE TABLE [dbo].[PIMS_INTEREST_HOLDER] ( [INTEREST_HOLDER_ID] bigint NOT NULL CONSTRAINT [INTHLD_INTEREST_HOLDER_ID_DEF] DEFAULT (NEXT VALUE FOR [PIMS_INTEREST_HOLDER_ID_SEQ]), + [ACQUISITION_FILE_ID] bigint NOT NULL, [PERSON_ID] bigint NULL, [ORGANIZATION_ID] bigint NULL, [IS_DISABLED] bit NULL CONSTRAINT [INTHLD_IS_DISABLED_DEF] DEFAULT (CONVERT([bit],(0))), @@ -235,7 +221,7 @@ GO PRINT N'Create table dbo.PIMS_INTHLDR_PROP_INTEREST' GO CREATE TABLE [dbo].[PIMS_INTHLDR_PROP_INTEREST] ( - [PIMS_INTHLDR_PROP_INTEREST_ID] varchar(40) NOT NULL CONSTRAINT [IHPRIN_PIMS_INTHLDR_PROP_INTEREST_ID_DEF] DEFAULT ('NEXT VALUE FOR [PIMS_INTHLDR_PROP_INTEREST_ID_SEQ]'), + [PIMS_INTHLDR_PROP_INTEREST_ID] bigint NOT NULL CONSTRAINT [IHPRIN_PIMS_INTHLDR_PROP_INTEREST_ID_DEF] DEFAULT (NEXT VALUE FOR [PIMS_INTHLDR_PROP_INTEREST_ID_SEQ]), [INTEREST_HOLDER_ID] bigint NOT NULL, [PROPERTY_ACQUISITION_FILE_ID] bigint NULL, [INTEREST_HOLDER_INTEREST_TYPE_CODE] nvarchar(20) NOT NULL, @@ -460,7 +446,8 @@ GO IF @@ERROR <> 0 SET NOEXEC ON GO ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE] - ADD [GST_NUMBER] nvarchar(50) NULL + ADD [GST_NUMBER] nvarchar(50) NULL, + [IS_PAYMENT_IN_TRUST] bit NULL CONSTRAINT [AQPCHQ_IS_PAYMENT_IN_TRUST_DEF] DEFAULT (CONVERT([bit],(0))) GO EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'GST number of the Payee' , @@ -480,7 +467,8 @@ GO PRINT N'Alter table dbo.PIMS_ACQ_PAYEE_CHEQUE_HIST' GO ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE_HIST] - ADD [GST_NUMBER] nvarchar(50) NULL + ADD [GST_NUMBER] nvarchar(50) NULL, + [IS_PAYMENT_IN_TRUST] bit NULL GO IF @@ERROR <> 0 SET NOEXEC ON GO @@ -513,6 +501,7 @@ CREATE TABLE [dbo].[PIMS_INTEREST_HOLDER_HIST] ( [EFFECTIVE_DATE_HIST] datetime NOT NULL DEFAULT (getutcdate()), [END_DATE_HIST] datetime NULL, [INTEREST_HOLDER_ID] bigint NOT NULL, + [ACQUISITION_FILE_ID] bigint NOT NULL, [PERSON_ID] bigint NULL, [ORGANIZATION_ID] bigint NULL, [IS_DISABLED] bit NULL, @@ -570,7 +559,7 @@ CREATE TABLE [dbo].[PIMS_INTHLDR_PROP_INTEREST_HIST] ( [_INTHLDR_PROP_INTEREST_HIST_ID] bigint NOT NULL DEFAULT (NEXT VALUE FOR [PIMS_INTHLDR_PROP_INTEREST_H_ID_SEQ]), [EFFECTIVE_DATE_HIST] datetime NOT NULL DEFAULT (getutcdate()), [END_DATE_HIST] datetime NULL, - [PIMS_INTHLDR_PROP_INTEREST_ID] varchar(40) NOT NULL, + [PIMS_INTHLDR_PROP_INTEREST_ID] bigint NOT NULL, [INTEREST_HOLDER_ID] bigint NOT NULL, [PROPERTY_ACQUISITION_FILE_ID] bigint NULL, [INTEREST_HOLDER_INTEREST_TYPE_CODE] nvarchar(20) NOT NULL, @@ -722,6 +711,19 @@ GO IF @@ERROR <> 0 SET NOEXEC ON GO +-- Create foreign key constraint dbo.PIM_ACQNFL_PIM_INTHLD_FK +PRINT N'Create foreign key constraint dbo.PIM_ACQNFL_PIM_INTHLD_FK' +GO +ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER] + ADD CONSTRAINT [PIM_ACQNFL_PIM_INTHLD_FK] + FOREIGN KEY([ACQUISITION_FILE_ID]) + REFERENCES [dbo].[PIMS_ACQUISITION_FILE]([ACQUISITION_FILE_ID]) + ON DELETE NO ACTION + ON UPDATE NO ACTION +GO +IF @@ERROR <> 0 SET NOEXEC ON +GO + -- Create foreign key constraint dbo.PIM_ORG_PIM_INTHLD_FK PRINT N'Create foreign key constraint dbo.PIM_ORG_PIM_INTHLD_FK' GO @@ -1055,6 +1057,7 @@ BEGIN TRY insert into PIMS_INTEREST_HOLDER ("INTEREST_HOLDER_ID", + "ACQUISITION_FILE_ID", "PERSON_ID", "ORGANIZATION_ID", "IS_DISABLED", @@ -1068,6 +1071,7 @@ BEGIN TRY "APP_LAST_UPDATE_USER_GUID", "APP_LAST_UPDATE_USER_DIRECTORY") select "INTEREST_HOLDER_ID", + "ACQUISITION_FILE_ID", "PERSON_ID", "ORGANIZATION_ID", "IS_DISABLED", @@ -1170,6 +1174,7 @@ BEGIN TRY "TAX_AMT" = inserted."TAX_AMT", "TOTAL_AMT" = inserted."TOTAL_AMT", "GST_NUMBER" = inserted."GST_NUMBER", + "IS_PAYMENT_IN_TRUST" = inserted."IS_PAYMENT_IN_TRUST", "CONCURRENCY_CONTROL_NUMBER" = inserted."CONCURRENCY_CONTROL_NUMBER", "APP_LAST_UPDATE_TIMESTAMP" = inserted."APP_LAST_UPDATE_TIMESTAMP", "APP_LAST_UPDATE_USERID" = inserted."APP_LAST_UPDATE_USERID", @@ -1207,8 +1212,8 @@ SET @curr_date = getutcdate(); update PIMS_ACQ_PAYEE_CHEQUE_HIST set END_DATE_HIST = @curr_date where ACQ_PAYEE_CHEQUE_ID in (select ACQ_PAYEE_CHEQUE_ID from deleted) and END_DATE_HIST is null; IF EXISTS(SELECT * FROM inserted) - insert into PIMS_ACQ_PAYEE_CHEQUE_HIST ([ACQ_PAYEE_CHEQUE_ID], [ACQUISITION_PAYEE_ID], [PRETAX_AMT], [TAX_AMT], [TOTAL_AMT], [GST_NUMBER], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _ACQ_PAYEE_CHEQUE_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST) - select [ACQ_PAYEE_CHEQUE_ID], [ACQUISITION_PAYEE_ID], [PRETAX_AMT], [TAX_AMT], [TOTAL_AMT], [GST_NUMBER], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_ACQ_PAYEE_CHEQUE_H_ID_SEQ]) as [_ACQ_PAYEE_CHEQUE_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted; + insert into PIMS_ACQ_PAYEE_CHEQUE_HIST ([ACQ_PAYEE_CHEQUE_ID], [ACQUISITION_PAYEE_ID], [PRETAX_AMT], [TAX_AMT], [TOTAL_AMT], [GST_NUMBER], [IS_PAYMENT_IN_TRUST], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _ACQ_PAYEE_CHEQUE_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST) + select [ACQ_PAYEE_CHEQUE_ID], [ACQUISITION_PAYEE_ID], [PRETAX_AMT], [TAX_AMT], [TOTAL_AMT], [GST_NUMBER], [IS_PAYMENT_IN_TRUST], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_ACQ_PAYEE_CHEQUE_H_ID_SEQ]) as [_ACQ_PAYEE_CHEQUE_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted; END TRY BEGIN CATCH @@ -1318,8 +1323,8 @@ SET @curr_date = getutcdate(); update PIMS_INTEREST_HOLDER_HIST set END_DATE_HIST = @curr_date where INTEREST_HOLDER_ID in (select INTEREST_HOLDER_ID from deleted) and END_DATE_HIST is null; IF EXISTS(SELECT * FROM inserted) - insert into PIMS_INTEREST_HOLDER_HIST ([INTEREST_HOLDER_ID], [PERSON_ID], [ORGANIZATION_ID], [IS_DISABLED], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _INTEREST_HOLDER_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST) - select [INTEREST_HOLDER_ID], [PERSON_ID], [ORGANIZATION_ID], [IS_DISABLED], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_INTEREST_HOLDER_H_ID_SEQ]) as [_INTEREST_HOLDER_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted; + insert into PIMS_INTEREST_HOLDER_HIST ([INTEREST_HOLDER_ID], [ACQUISITION_FILE_ID], [PERSON_ID], [ORGANIZATION_ID], [IS_DISABLED], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _INTEREST_HOLDER_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST) + select [INTEREST_HOLDER_ID], [ACQUISITION_FILE_ID], [PERSON_ID], [ORGANIZATION_ID], [IS_DISABLED], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_INTEREST_HOLDER_H_ID_SEQ]) as [_INTEREST_HOLDER_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted; END TRY BEGIN CATCH @@ -1347,6 +1352,7 @@ BEGIN TRY "TAX_AMT", "TOTAL_AMT", "GST_NUMBER", + "IS_PAYMENT_IN_TRUST", "CONCURRENCY_CONTROL_NUMBER", "APP_CREATE_TIMESTAMP", "APP_CREATE_USERID", @@ -1362,6 +1368,7 @@ BEGIN TRY "TAX_AMT", "TOTAL_AMT", "GST_NUMBER", + "IS_PAYMENT_IN_TRUST", "CONCURRENCY_CONTROL_NUMBER", "APP_CREATE_TIMESTAMP", "APP_CREATE_USERID", @@ -1479,6 +1486,7 @@ BEGIN TRY -- update statement update PIMS_INTEREST_HOLDER set "INTEREST_HOLDER_ID" = inserted."INTEREST_HOLDER_ID", + "ACQUISITION_FILE_ID" = inserted."ACQUISITION_FILE_ID", "PERSON_ID" = inserted."PERSON_ID", "ORGANIZATION_ID" = inserted."ORGANIZATION_ID", "IS_DISABLED" = inserted."IS_DISABLED", diff --git a/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Alter Up/003_Delete_DynamicConstraint.sql b/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Alter Up/003_Delete_DynamicConstraint.sql deleted file mode 100644 index aa8ee2306e..0000000000 --- a/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Alter Up/003_Delete_DynamicConstraint.sql +++ /dev/null @@ -1,30 +0,0 @@ --- Drop dynamically-named default constraints -PRINT N'Drop dynamically-named default constraints' -GO -DECLARE @sqlQry VARCHAR(1000) -DECLARE @defName VARCHAR(100) -SET @defName = (SELECT obj.NAME - FROM SYSOBJECTS obj INNER JOIN - SYSCOLUMNS col on obj.ID = col.CDEFAULT INNER JOIN - SYSOBJECTS tbl on col.ID = tbl.ID - WHERE obj.XTYPE = 'D' - AND tbl.NAME = 'PIMS_COMP_REQ_H120' - AND col.NAME = 'FINANCIAL_ACTIVITY_CODE_ID') -SET @sqlQry = 'ALTER TABLE [dbo].[PIMS_COMP_REQ_H120] DROP CONSTRAINT IF EXISTS [' + @defName + ']' -EXEC (@sqlQry) -IF @@ERROR <> 0 SET NOEXEC ON -GO - -DECLARE @sqlQry VARCHAR(1000) -DECLARE @defName VARCHAR(100) -SET @defName = (SELECT obj.NAME - FROM SYSOBJECTS obj INNER JOIN - SYSCOLUMNS col on obj.ID = col.CDEFAULT INNER JOIN - SYSOBJECTS tbl on col.ID = tbl.ID - WHERE obj.XTYPE = 'D' - AND tbl.NAME = 'PIMS_COMP_REQ_H120_HIST' - AND col.NAME = 'FINANCIAL_ACTIVITY_CODE_ID') -SET @sqlQry = 'ALTER TABLE [dbo].[PIMS_COMP_REQ_H120] DROP CONSTRAINT IF EXISTS [' + @defName + ']' -EXEC (@sqlQry) -IF @@ERROR <> 0 SET NOEXEC ON -GO diff --git a/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Alter Up/007_Add_Aquisiton_File_FK.sql b/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Alter Up/007_Add_Aquisiton_File_FK.sql deleted file mode 100644 index 571ca50fe0..0000000000 --- a/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Alter Up/007_Add_Aquisiton_File_FK.sql +++ /dev/null @@ -1,15 +0,0 @@ -/* ----------------------------------------------------------------------------- -Add foreign key from PIMS_ACQUISITION_FILE to PIMS_INTEREST_HOLDER. -. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -Author Date Comment ------------- ----------- ----------------------------------------------------- -Doug Filteau 2023-May-29 Initial version ------------------------------------------------------------------------------ */ - -ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER] - ADD [ACQUISITION_FILE_ID] BIGINT NOT NULL -GO - -ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER] ADD CONSTRAINT [PIM_ACQNFL_PIM_INTHLD_FK] - FOREIGN KEY ([ACQUISITION_FILE_ID]) REFERENCES [dbo].[PIMS_ACQUISITION_FILE] ([ACQUISITION_FILE_ID]) -GO diff --git a/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Build/002_PSP_PIMS_Build.sql b/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Build/002_PSP_PIMS_Build.sql index 4196e3d362..356fa0417c 100644 --- a/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Build/002_PSP_PIMS_Build.sql +++ b/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Build/002_PSP_PIMS_Build.sql @@ -1,5 +1,5 @@ /* -Script generated by Aqua Data Studio 22.2.0 on May-26-2023 11:44:32 a.m. +Script generated by Aqua Data Studio 22.2.0 on May-30-2023 01:59:14 p.m. Database: PIMS_PSP_S55_00 Schema: dbo Objects: DATATYPE, DEFAULT, RULE, SEQUENCE, TABLE, VIEW, SYNONYM, PROCEDURE, FUNCTION, INDEX, TRIGGER, DATABASETRIGGER, DATABASE_AUDIT_SPEC @@ -224,16 +224,6 @@ CREATE SEQUENCE [dbo].[PIMS_ACQUISITION_FILE_PERSON_ID_SEQ] CACHE 50 GO ---CREATE SEQUENCE [dbo].[PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ] --- AS bigint --- START WITH 1 --- INCREMENT BY 1 --- MINVALUE 1 --- MAXVALUE 2147483647 --- NO CYCLE --- CACHE 50 ---GO - CREATE SEQUENCE [dbo].[PIMS_ACQUISITION_OWNER_H_ID_SEQ] AS bigint START WITH 1 @@ -4891,6 +4881,7 @@ GO CREATE TABLE [dbo].[PIMS_INTEREST_HOLDER] ( [INTEREST_HOLDER_ID] bigint NOT NULL CONSTRAINT [INTHLD_INTEREST_HOLDER_ID_DEF] DEFAULT (NEXT VALUE FOR [PIMS_INTEREST_HOLDER_ID_SEQ]), + [ACQUISITION_FILE_ID] bigint NOT NULL, [PERSON_ID] bigint NULL, [ORGANIZATION_ID] bigint NULL, [IS_DISABLED] bit NULL CONSTRAINT [INTHLD_IS_DISABLED_DEF] DEFAULT (CONVERT([bit],(0))), @@ -4995,6 +4986,7 @@ CREATE TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE] ( [TAX_AMT] money NULL, [TOTAL_AMT] money NULL, [GST_NUMBER] nvarchar(50) NULL, + [IS_PAYMENT_IN_TRUST] bit NULL CONSTRAINT [AQPCHQ_IS_PAYMENT_IN_TRUST_DEF] DEFAULT (CONVERT([bit],(0))), [CONCURRENCY_CONTROL_NUMBER] bigint NOT NULL CONSTRAINT [AQPCHQ_CONCURRENCY_CONTROL_NUMBER_DEF] DEFAULT ((1)), [APP_CREATE_TIMESTAMP] datetime NOT NULL CONSTRAINT [AQPCHQ_APP_CREATE_TIMESTAMP_DEF] DEFAULT (getutcdate()), [APP_CREATE_USERID] nvarchar(30) NOT NULL CONSTRAINT [AQPCHQ_APP_CREATE_USERID_DEF] DEFAULT (user_name()), @@ -5051,6 +5043,7 @@ CREATE TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE_HIST] ( [TAX_AMT] money NULL, [TOTAL_AMT] money NULL, [GST_NUMBER] nvarchar(50) NULL, + [IS_PAYMENT_IN_TRUST] bit NULL, [CONCURRENCY_CONTROL_NUMBER] bigint NOT NULL, [APP_CREATE_TIMESTAMP] datetime NOT NULL, [APP_CREATE_USERID] nvarchar(30) NOT NULL, @@ -7870,6 +7863,7 @@ CREATE TABLE [dbo].[PIMS_INTEREST_HOLDER_HIST] ( [EFFECTIVE_DATE_HIST] datetime NOT NULL DEFAULT (getutcdate()), [END_DATE_HIST] datetime NULL, [INTEREST_HOLDER_ID] bigint NOT NULL, + [ACQUISITION_FILE_ID] bigint NOT NULL, [PERSON_ID] bigint NULL, [ORGANIZATION_ID] bigint NULL, [IS_DISABLED] bit NULL, @@ -7934,7 +7928,7 @@ EXEC sp_addextendedproperty GO CREATE TABLE [dbo].[PIMS_INTHLDR_PROP_INTEREST] ( - [PIMS_INTHLDR_PROP_INTEREST_ID] varchar(40) NOT NULL CONSTRAINT [IHPRIN_PIMS_INTHLDR_PROP_INTEREST_ID_DEF] DEFAULT ('NEXT VALUE FOR [PIMS_INTHLDR_PROP_INTEREST_ID_SEQ]'), + [PIMS_INTHLDR_PROP_INTEREST_ID] bigint NOT NULL CONSTRAINT [IHPRIN_PIMS_INTHLDR_PROP_INTEREST_ID_DEF] DEFAULT (NEXT VALUE FOR [PIMS_INTHLDR_PROP_INTEREST_ID_SEQ]), [INTEREST_HOLDER_ID] bigint NOT NULL, [PROPERTY_ACQUISITION_FILE_ID] bigint NULL, [INTEREST_HOLDER_INTEREST_TYPE_CODE] nvarchar(20) NOT NULL, @@ -7966,7 +7960,7 @@ CREATE TABLE [dbo].[PIMS_INTHLDR_PROP_INTEREST_HIST] ( [_INTHLDR_PROP_INTEREST_HIST_ID] bigint NOT NULL DEFAULT (NEXT VALUE FOR [PIMS_INTHLDR_PROP_INTEREST_H_ID_SEQ]), [EFFECTIVE_DATE_HIST] datetime NOT NULL DEFAULT (getutcdate()), [END_DATE_HIST] datetime NULL, - [PIMS_INTHLDR_PROP_INTEREST_ID] varchar(40) NOT NULL, + [PIMS_INTHLDR_PROP_INTEREST_ID] bigint NOT NULL, [INTEREST_HOLDER_ID] bigint NOT NULL, [PROPERTY_ACQUISITION_FILE_ID] bigint NULL, [INTEREST_HOLDER_INTEREST_TYPE_CODE] nvarchar(20) NOT NULL, @@ -11884,6 +11878,7 @@ WITH AND CON.RN = 1 GO + CREATE VIEW [dbo].[PIMS_PROPERTY_BOUNDARY_VW] AS SELECT PROP.PROPERTY_ID , PROP.PID @@ -13031,106 +13026,6 @@ CREATE NONCLUSTERED INDEX [YRFINC_CODE_IDX] ON [dbo].[PIMS_YEARLY_FINANCIAL_CODE]([CODE]) GO -CREATE TRIGGER [dbo].[PIMS_CLMTYP_I_S_I_TR] ON PIMS_CLAIM INSTEAD OF INSERT AS -SET NOCOUNT ON -BEGIN TRY - IF NOT EXISTS(SELECT * FROM inserted) - RETURN; - - - insert into PIMS_CLAIM ("CLAIM_ID", - "CLAIM_UID", - "KEYCLOAK_ROLE_ID", - "NAME", - "DESCRIPTION", - "IS_DISABLED", - "CONCURRENCY_CONTROL_NUMBER", - "APP_CREATE_TIMESTAMP", - "APP_CREATE_USERID", - "APP_CREATE_USER_GUID", - "APP_CREATE_USER_DIRECTORY", - "APP_LAST_UPDATE_TIMESTAMP", - "APP_LAST_UPDATE_USERID", - "APP_LAST_UPDATE_USER_GUID", - "APP_LAST_UPDATE_USER_DIRECTORY") - select "CLAIM_ID", - "CLAIM_UID", - "KEYCLOAK_ROLE_ID", - "NAME", - "DESCRIPTION", - "IS_DISABLED", - "CONCURRENCY_CONTROL_NUMBER", - "APP_CREATE_TIMESTAMP", - "APP_CREATE_USERID", - "APP_CREATE_USER_GUID", - "APP_CREATE_USER_DIRECTORY", - "APP_LAST_UPDATE_TIMESTAMP", - "APP_LAST_UPDATE_USERID", - "APP_LAST_UPDATE_USER_GUID", - "APP_LAST_UPDATE_USER_DIRECTORY" - from inserted; - -END TRY -BEGIN CATCH - IF @@trancount > 0 ROLLBACK TRANSACTION - EXEC pims_error_handling -END CATCH; -GO - -CREATE TRIGGER [dbo].[PIMS_LELIST_I_S_U_TR] ON PIMS_LEASE_LICENSE_TYPE INSTEAD OF UPDATE AS -SET NOCOUNT ON -BEGIN TRY - IF NOT EXISTS(SELECT * FROM deleted) - RETURN; - - -- validate concurrency control - if exists (select 1 from inserted, deleted where inserted.CONCURRENCY_CONTROL_NUMBER != deleted.CONCURRENCY_CONTROL_NUMBER+1 AND inserted.LEASE_LICENSE_TYPE_CODE = deleted.LEASE_LICENSE_TYPE_CODE) - raiserror('CONCURRENCY FAILURE.',16,1) - - - -- update statement - update PIMS_LEASE_LICENSE_TYPE - set "LEASE_LICENSE_TYPE_CODE" = inserted."LEASE_LICENSE_TYPE_CODE", - "DESCRIPTION" = inserted."DESCRIPTION", - "IS_DISABLED" = inserted."IS_DISABLED", - "DISPLAY_ORDER" = inserted."DISPLAY_ORDER", - "CONCURRENCY_CONTROL_NUMBER" = inserted."CONCURRENCY_CONTROL_NUMBER" - , DB_LAST_UPDATE_TIMESTAMP = getutcdate() - , DB_LAST_UPDATE_USERID = user_name() - from PIMS_LEASE_LICENSE_TYPE - inner join inserted - on (PIMS_LEASE_LICENSE_TYPE.LEASE_LICENSE_TYPE_CODE = inserted.LEASE_LICENSE_TYPE_CODE); - -END TRY -BEGIN CATCH - IF @@trancount > 0 ROLLBACK TRANSACTION - EXEC pims_error_handling -END CATCH; -GO - -CREATE TRIGGER [dbo].[PIMS_CNTMTH_A_S_IUD_TR] ON PIMS_CONTACT_METHOD FOR INSERT, UPDATE, DELETE AS -SET NOCOUNT ON -BEGIN TRY -DECLARE @curr_date datetime; -SET @curr_date = getutcdate(); - IF NOT EXISTS(SELECT * FROM inserted) AND NOT EXISTS(SELECT * FROM deleted) - RETURN; - - -- historical - IF EXISTS(SELECT * FROM deleted) - update PIMS_CONTACT_METHOD_HIST set END_DATE_HIST = @curr_date where CONTACT_METHOD_ID in (select CONTACT_METHOD_ID from deleted) and END_DATE_HIST is null; - - IF EXISTS(SELECT * FROM inserted) - insert into PIMS_CONTACT_METHOD_HIST ([CONTACT_METHOD_ID], [CONTACT_METHOD_TYPE_CODE], [PERSON_ID], [ORGANIZATION_ID], [CONTACT_METHOD_VALUE], [IS_PREFERRED_METHOD], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _CONTACT_METHOD_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST) - select [CONTACT_METHOD_ID], [CONTACT_METHOD_TYPE_CODE], [PERSON_ID], [ORGANIZATION_ID], [CONTACT_METHOD_VALUE], [IS_PREFERRED_METHOD], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_CONTACT_METHOD_H_ID_SEQ]) as [_CONTACT_METHOD_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted; - -END TRY -BEGIN CATCH - IF @@trancount > 0 ROLLBACK TRANSACTION - EXEC pims_error_handling -END CATCH; -GO - CREATE TRIGGER [dbo].[PIMS_CRH120_I_S_I_TR] ON PIMS_COMP_REQ_H120 INSTEAD OF INSERT AS SET NOCOUNT ON BEGIN TRY @@ -13957,8 +13852,8 @@ SET @curr_date = getutcdate(); update PIMS_INTEREST_HOLDER_HIST set END_DATE_HIST = @curr_date where INTEREST_HOLDER_ID in (select INTEREST_HOLDER_ID from deleted) and END_DATE_HIST is null; IF EXISTS(SELECT * FROM inserted) - insert into PIMS_INTEREST_HOLDER_HIST ([INTEREST_HOLDER_ID], [PERSON_ID], [ORGANIZATION_ID], [IS_DISABLED], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _INTEREST_HOLDER_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST) - select [INTEREST_HOLDER_ID], [PERSON_ID], [ORGANIZATION_ID], [IS_DISABLED], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_INTEREST_HOLDER_H_ID_SEQ]) as [_INTEREST_HOLDER_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted; + insert into PIMS_INTEREST_HOLDER_HIST ([INTEREST_HOLDER_ID], [ACQUISITION_FILE_ID], [PERSON_ID], [ORGANIZATION_ID], [IS_DISABLED], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _INTEREST_HOLDER_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST) + select [INTEREST_HOLDER_ID], [ACQUISITION_FILE_ID], [PERSON_ID], [ORGANIZATION_ID], [IS_DISABLED], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_INTEREST_HOLDER_H_ID_SEQ]) as [_INTEREST_HOLDER_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted; END TRY BEGIN CATCH @@ -15187,6 +15082,7 @@ BEGIN TRY insert into PIMS_INTEREST_HOLDER ("INTEREST_HOLDER_ID", + "ACQUISITION_FILE_ID", "PERSON_ID", "ORGANIZATION_ID", "IS_DISABLED", @@ -15200,6 +15096,7 @@ BEGIN TRY "APP_LAST_UPDATE_USER_GUID", "APP_LAST_UPDATE_USER_DIRECTORY") select "INTEREST_HOLDER_ID", + "ACQUISITION_FILE_ID", "PERSON_ID", "ORGANIZATION_ID", "IS_DISABLED", @@ -19636,6 +19533,7 @@ BEGIN TRY "TAX_AMT" = inserted."TAX_AMT", "TOTAL_AMT" = inserted."TOTAL_AMT", "GST_NUMBER" = inserted."GST_NUMBER", + "IS_PAYMENT_IN_TRUST" = inserted."IS_PAYMENT_IN_TRUST", "CONCURRENCY_CONTROL_NUMBER" = inserted."CONCURRENCY_CONTROL_NUMBER", "APP_LAST_UPDATE_TIMESTAMP" = inserted."APP_LAST_UPDATE_TIMESTAMP", "APP_LAST_UPDATE_USERID" = inserted."APP_LAST_UPDATE_USERID", @@ -23302,6 +23200,7 @@ BEGIN TRY "TAX_AMT", "TOTAL_AMT", "GST_NUMBER", + "IS_PAYMENT_IN_TRUST", "CONCURRENCY_CONTROL_NUMBER", "APP_CREATE_TIMESTAMP", "APP_CREATE_USERID", @@ -23317,6 +23216,7 @@ BEGIN TRY "TAX_AMT", "TOTAL_AMT", "GST_NUMBER", + "IS_PAYMENT_IN_TRUST", "CONCURRENCY_CONTROL_NUMBER", "APP_CREATE_TIMESTAMP", "APP_CREATE_USERID", @@ -26100,6 +26000,7 @@ BEGIN TRY -- update statement update PIMS_INTEREST_HOLDER set "INTEREST_HOLDER_ID" = inserted."INTEREST_HOLDER_ID", + "ACQUISITION_FILE_ID" = inserted."ACQUISITION_FILE_ID", "PERSON_ID" = inserted."PERSON_ID", "ORGANIZATION_ID" = inserted."ORGANIZATION_ID", "IS_DISABLED" = inserted."IS_DISABLED", @@ -26938,8 +26839,8 @@ SET @curr_date = getutcdate(); update PIMS_ACQ_PAYEE_CHEQUE_HIST set END_DATE_HIST = @curr_date where ACQ_PAYEE_CHEQUE_ID in (select ACQ_PAYEE_CHEQUE_ID from deleted) and END_DATE_HIST is null; IF EXISTS(SELECT * FROM inserted) - insert into PIMS_ACQ_PAYEE_CHEQUE_HIST ([ACQ_PAYEE_CHEQUE_ID], [ACQUISITION_PAYEE_ID], [PRETAX_AMT], [TAX_AMT], [TOTAL_AMT], [GST_NUMBER], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _ACQ_PAYEE_CHEQUE_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST) - select [ACQ_PAYEE_CHEQUE_ID], [ACQUISITION_PAYEE_ID], [PRETAX_AMT], [TAX_AMT], [TOTAL_AMT], [GST_NUMBER], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_ACQ_PAYEE_CHEQUE_H_ID_SEQ]) as [_ACQ_PAYEE_CHEQUE_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted; + insert into PIMS_ACQ_PAYEE_CHEQUE_HIST ([ACQ_PAYEE_CHEQUE_ID], [ACQUISITION_PAYEE_ID], [PRETAX_AMT], [TAX_AMT], [TOTAL_AMT], [GST_NUMBER], [IS_PAYMENT_IN_TRUST], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _ACQ_PAYEE_CHEQUE_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST) + select [ACQ_PAYEE_CHEQUE_ID], [ACQUISITION_PAYEE_ID], [PRETAX_AMT], [TAX_AMT], [TOTAL_AMT], [GST_NUMBER], [IS_PAYMENT_IN_TRUST], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_ACQ_PAYEE_CHEQUE_H_ID_SEQ]) as [_ACQ_PAYEE_CHEQUE_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted; END TRY BEGIN CATCH @@ -27318,6 +27219,106 @@ BEGIN CATCH END CATCH; GO +CREATE TRIGGER [dbo].[PIMS_CLMTYP_I_S_I_TR] ON PIMS_CLAIM INSTEAD OF INSERT AS +SET NOCOUNT ON +BEGIN TRY + IF NOT EXISTS(SELECT * FROM inserted) + RETURN; + + + insert into PIMS_CLAIM ("CLAIM_ID", + "CLAIM_UID", + "KEYCLOAK_ROLE_ID", + "NAME", + "DESCRIPTION", + "IS_DISABLED", + "CONCURRENCY_CONTROL_NUMBER", + "APP_CREATE_TIMESTAMP", + "APP_CREATE_USERID", + "APP_CREATE_USER_GUID", + "APP_CREATE_USER_DIRECTORY", + "APP_LAST_UPDATE_TIMESTAMP", + "APP_LAST_UPDATE_USERID", + "APP_LAST_UPDATE_USER_GUID", + "APP_LAST_UPDATE_USER_DIRECTORY") + select "CLAIM_ID", + "CLAIM_UID", + "KEYCLOAK_ROLE_ID", + "NAME", + "DESCRIPTION", + "IS_DISABLED", + "CONCURRENCY_CONTROL_NUMBER", + "APP_CREATE_TIMESTAMP", + "APP_CREATE_USERID", + "APP_CREATE_USER_GUID", + "APP_CREATE_USER_DIRECTORY", + "APP_LAST_UPDATE_TIMESTAMP", + "APP_LAST_UPDATE_USERID", + "APP_LAST_UPDATE_USER_GUID", + "APP_LAST_UPDATE_USER_DIRECTORY" + from inserted; + +END TRY +BEGIN CATCH + IF @@trancount > 0 ROLLBACK TRANSACTION + EXEC pims_error_handling +END CATCH; +GO + +CREATE TRIGGER [dbo].[PIMS_LELIST_I_S_U_TR] ON PIMS_LEASE_LICENSE_TYPE INSTEAD OF UPDATE AS +SET NOCOUNT ON +BEGIN TRY + IF NOT EXISTS(SELECT * FROM deleted) + RETURN; + + -- validate concurrency control + if exists (select 1 from inserted, deleted where inserted.CONCURRENCY_CONTROL_NUMBER != deleted.CONCURRENCY_CONTROL_NUMBER+1 AND inserted.LEASE_LICENSE_TYPE_CODE = deleted.LEASE_LICENSE_TYPE_CODE) + raiserror('CONCURRENCY FAILURE.',16,1) + + + -- update statement + update PIMS_LEASE_LICENSE_TYPE + set "LEASE_LICENSE_TYPE_CODE" = inserted."LEASE_LICENSE_TYPE_CODE", + "DESCRIPTION" = inserted."DESCRIPTION", + "IS_DISABLED" = inserted."IS_DISABLED", + "DISPLAY_ORDER" = inserted."DISPLAY_ORDER", + "CONCURRENCY_CONTROL_NUMBER" = inserted."CONCURRENCY_CONTROL_NUMBER" + , DB_LAST_UPDATE_TIMESTAMP = getutcdate() + , DB_LAST_UPDATE_USERID = user_name() + from PIMS_LEASE_LICENSE_TYPE + inner join inserted + on (PIMS_LEASE_LICENSE_TYPE.LEASE_LICENSE_TYPE_CODE = inserted.LEASE_LICENSE_TYPE_CODE); + +END TRY +BEGIN CATCH + IF @@trancount > 0 ROLLBACK TRANSACTION + EXEC pims_error_handling +END CATCH; +GO + +CREATE TRIGGER [dbo].[PIMS_CNTMTH_A_S_IUD_TR] ON PIMS_CONTACT_METHOD FOR INSERT, UPDATE, DELETE AS +SET NOCOUNT ON +BEGIN TRY +DECLARE @curr_date datetime; +SET @curr_date = getutcdate(); + IF NOT EXISTS(SELECT * FROM inserted) AND NOT EXISTS(SELECT * FROM deleted) + RETURN; + + -- historical + IF EXISTS(SELECT * FROM deleted) + update PIMS_CONTACT_METHOD_HIST set END_DATE_HIST = @curr_date where CONTACT_METHOD_ID in (select CONTACT_METHOD_ID from deleted) and END_DATE_HIST is null; + + IF EXISTS(SELECT * FROM inserted) + insert into PIMS_CONTACT_METHOD_HIST ([CONTACT_METHOD_ID], [CONTACT_METHOD_TYPE_CODE], [PERSON_ID], [ORGANIZATION_ID], [CONTACT_METHOD_VALUE], [IS_PREFERRED_METHOD], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], _CONTACT_METHOD_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST) + select [CONTACT_METHOD_ID], [CONTACT_METHOD_TYPE_CODE], [PERSON_ID], [ORGANIZATION_ID], [CONTACT_METHOD_VALUE], [IS_PREFERRED_METHOD], [CONCURRENCY_CONTROL_NUMBER], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [DB_CREATE_TIMESTAMP], [DB_CREATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], (next value for [dbo].[PIMS_CONTACT_METHOD_H_ID_SEQ]) as [_CONTACT_METHOD_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted; + +END TRY +BEGIN CATCH + IF @@trancount > 0 ROLLBACK TRANSACTION + EXEC pims_error_handling +END CATCH; +GO + ALTER TABLE [dbo].[PIMS_ACCESS_REQUEST] ADD CONSTRAINT [ACRQST_USER_ROLE_REGION_TUC] @@ -28959,6 +28960,14 @@ ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER] ON UPDATE NO ACTION GO +ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER] + ADD CONSTRAINT [PIM_ACQNFL_PIM_INTHLD_FK] + FOREIGN KEY([ACQUISITION_FILE_ID]) + REFERENCES [dbo].[PIMS_ACQUISITION_FILE]([ACQUISITION_FILE_ID]) + ON DELETE NO ACTION + ON UPDATE NO ACTION +GO + ALTER TABLE [dbo].[PIMS_ACQUISITION_PAYEE] ADD CONSTRAINT [PIM_INTHLD_PIM_ACQPAY_FK] FOREIGN KEY([INTEREST_HOLDER_ID]) diff --git a/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Build/007_Add_Aquisiton_File_FK.sql b/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Build/007_Add_Aquisiton_File_FK.sql deleted file mode 100644 index 571ca50fe0..0000000000 --- a/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Build/007_Add_Aquisiton_File_FK.sql +++ /dev/null @@ -1,15 +0,0 @@ -/* ----------------------------------------------------------------------------- -Add foreign key from PIMS_ACQUISITION_FILE to PIMS_INTEREST_HOLDER. -. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -Author Date Comment ------------- ----------- ----------------------------------------------------- -Doug Filteau 2023-May-29 Initial version ------------------------------------------------------------------------------ */ - -ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER] - ADD [ACQUISITION_FILE_ID] BIGINT NOT NULL -GO - -ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER] ADD CONSTRAINT [PIM_ACQNFL_PIM_INTHLD_FK] - FOREIGN KEY ([ACQUISITION_FILE_ID]) REFERENCES [dbo].[PIMS_ACQUISITION_FILE] ([ACQUISITION_FILE_ID]) -GO diff --git a/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Drop/01_PSP_PIMS_Drop.sql b/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Drop/01_PSP_PIMS_Drop.sql index c8d77b852d..e15cdf3473 100644 --- a/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Drop/01_PSP_PIMS_Drop.sql +++ b/source/database/mssql/scripts/dbscripts/PSP_PIMS_S55_00/Drop/01_PSP_PIMS_Drop.sql @@ -5,7 +5,7 @@ /* Project name: MoTI Property Services Project */ /* Author: Doug Filteau */ /* Script type: Database drop script */ -/* Created on: 2023-05-26 11:18 */ +/* Created on: 2023-05-30 13:44 */ /* ---------------------------------------------------------------------- */ @@ -2521,6 +2521,10 @@ ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER] DROP CONSTRAINT [PIM_ORG_PIM_INTHLD_FK] GO +ALTER TABLE [dbo].[PIMS_INTEREST_HOLDER] DROP CONSTRAINT [PIM_ACQNFL_PIM_INTHLD_FK] +GO + + ALTER TABLE [dbo].[PIMS_ACQUISITION_OWNER_REP] DROP CONSTRAINT [PIM_ACQNFL_PIM_AQOWRP_FK] GO @@ -3151,6 +3155,10 @@ ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE] DROP CONSTRAINT [AQPCHQ_ACQ_PAYEE_CHEQ GO +ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE] DROP CONSTRAINT [AQPCHQ_IS_PAYMENT_IN_TRUST_DEF] +GO + + ALTER TABLE [dbo].[PIMS_ACQ_PAYEE_CHEQUE] DROP CONSTRAINT [AQPCHQ_CONCURRENCY_CONTROL_NUMBER_DEF] GO @@ -14623,10 +14631,6 @@ DROP SEQUENCE [dbo].[PIMS_INTEREST_HOLDER_PROPERTY_ID_SEQ] GO -DROP SEQUENCE [dbo].[PIMS_ACQUISITION_FILE_STAKEHOLDER_ID_SEQ] -GO - - DROP SEQUENCE [dbo].[PIMS_OWNER_REPRESENTATIVE_ID_SEQ] GO diff --git a/source/frontend/package.json b/source/frontend/package.json index 370500bcb5..77368d07fe 100644 --- a/source/frontend/package.json +++ b/source/frontend/package.json @@ -1,6 +1,6 @@ { "name": "frontend", - "version": "3.2.0-55.3", + "version": "3.2.0-55.5", "private": true, "dependencies": { "@bcgov/bc-sans": "1.0.1",