Skip to content

Commit

Permalink
CNDE-2043 (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-mills-cdw authored Jan 2, 2025
1 parent da889bc commit 1b69d25
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,6 @@ BEGIN
' WHERE
ix.D_INTERVIEW_KEY IS NOT NULL;';

SELECT @Update_sql;

exec sp_executesql @Update_sql;


Expand Down
26 changes: 15 additions & 11 deletions db/upgrade/rdb_modern/tables/022-create_nrt_interview_key.sql
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
DROP TABLE IF EXISTS dbo.nrt_interview_key;
-- table is not dropped and recreated, as D_INTERVIEW_KEY does not retain the key-uid relationship

CREATE TABLE dbo.nrt_interview_key (
d_interview_key bigint IDENTITY(1,1) NOT NULL,
interview_uid bigint NULL
);
IF NOT EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_interview_key' and xtype = 'U')
BEGIN

declare @max bigint;
select @max=max(D_INTERVIEW_KEY)+1 from dbo.D_INTERVIEW;
select @max;
if @max IS NULL --check when max is returned as null
SET @max = 1;
DBCC CHECKIDENT ('dbo.nrt_interview_key', RESEED, @max);
CREATE TABLE dbo.nrt_interview_key (
d_interview_key bigint IDENTITY (1,1) NOT NULL,
interview_uid bigint NULL
);
declare @max bigint;
select @max=max(d_interview_key)+1 from dbo.D_INTERVIEW ;
select @max;
if @max IS NULL --check when max is returned as null
SET @max = 2; -- default to 2, as default record with key = 1 is not stored in D_INTERVIEW
DBCC CHECKIDENT ('dbo.nrt_interview_key', RESEED, @max);

END
28 changes: 16 additions & 12 deletions db/upgrade/rdb_modern/tables/022-create_nrt_interview_note_key.sql
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
DROP TABLE IF EXISTS dbo.nrt_interview_note_key;
-- table is not dropped and recreated so as to stay consistent with the design of nrt_interview_key

CREATE TABLE dbo.nrt_interview_note_key (
d_interview_note_key bigint IDENTITY(1,1) NOT NULL,
d_interview_key bigint NOT NULL,
nbs_answer_uid bigint NULL
);
IF NOT EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_interview_note_key' and xtype = 'U')
BEGIN

declare @max bigint;
select @max=max(D_INTERVIEW_NOTE_KEY)+1 from dbo.D_INTERVIEW_NOTE;
select @max;
if @max IS NULL --check when max is returned as null
SET @max = 1;
DBCC CHECKIDENT ('dbo.nrt_interview_note_key', RESEED, @max);
CREATE TABLE dbo.nrt_interview_note_key (
d_interview_note_key bigint IDENTITY(1,1) NOT NULL,
d_interview_key bigint NOT NULL,
nbs_answer_uid bigint NULL
);
declare @max bigint;
select @max=max(d_interview_note_key)+1 from dbo.D_INTERVIEW_NOTE ;
select @max;
if @max IS NULL --check when max is returned as null
SET @max = 2; -- default to 2, as default record with key = 1 is not stored in D_INTERVIEW_NOTE
DBCC CHECKIDENT ('dbo.nrt_interview_note_key', RESEED, @max);

END
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,6 @@ BEGIN
' WHERE
ix.D_INTERVIEW_KEY IS NOT NULL;';

SELECT @Update_sql;

exec sp_executesql @Update_sql;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
DROP TABLE IF EXISTS dbo.nrt_interview_key;
-- table is not dropped and recreated, as D_INTERVIEW_KEY does not retain the key-uid relationship

CREATE TABLE dbo.nrt_interview_key (
d_interview_key bigint IDENTITY(1,1) NOT NULL,
interview_uid bigint NULL
);
IF NOT EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_interview_key' and xtype = 'U')
BEGIN

declare @max bigint;
select @max=max(D_INTERVIEW_KEY)+1 from dbo.D_INTERVIEW;
select @max;
if @max IS NULL --check when max is returned as null
SET @max = 1;
DBCC CHECKIDENT ('dbo.nrt_interview_key', RESEED, @max);
CREATE TABLE dbo.nrt_interview_key (
d_interview_key bigint IDENTITY (1,1) NOT NULL,
interview_uid bigint NULL
);
declare @max bigint;
select @max=max(d_interview_key)+1 from dbo.D_INTERVIEW ;
select @max;
if @max IS NULL --check when max is returned as null
SET @max = 2; -- default to 2, as default record with key = 1 is not stored in D_INTERVIEW
DBCC CHECKIDENT ('dbo.nrt_interview_key', RESEED, @max);

END
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
DROP TABLE IF EXISTS dbo.nrt_interview_note_key;
-- table is not dropped and recreated so as to stay consistent with the design of nrt_interview_key

CREATE TABLE dbo.nrt_interview_note_key (
d_interview_note_key bigint IDENTITY(1,1) NOT NULL,
d_interview_key bigint NOT NULL,
nbs_answer_uid bigint NULL
);
IF NOT EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_interview_note_key' and xtype = 'U')
BEGIN

declare @max bigint;
select @max=max(D_INTERVIEW_NOTE_KEY)+1 from dbo.D_INTERVIEW_NOTE;
select @max;
if @max IS NULL --check when max is returned as null
SET @max = 1;
DBCC CHECKIDENT ('dbo.nrt_interview_note_key', RESEED, @max);
CREATE TABLE dbo.nrt_interview_note_key (
d_interview_note_key bigint IDENTITY(1,1) NOT NULL,
d_interview_key bigint NOT NULL,
nbs_answer_uid bigint NULL
);
declare @max bigint;
select @max=max(d_interview_note_key)+1 from dbo.D_INTERVIEW_NOTE ;
select @max;
if @max IS NULL --check when max is returned as null
SET @max = 2; -- default to 2, as default record with key = 1 is not stored in D_INTERVIEW_NOTE
DBCC CHECKIDENT ('dbo.nrt_interview_note_key', RESEED, @max);

END

0 comments on commit 1b69d25

Please sign in to comment.