CREATE TABLE transcript_history (transcript_history_id nvarchar(85) NOT NULL, transcript_id nvarchar(15) NOT NULL, user_id nvarchar(85) NOT NULL, learning_id nvarchar(85) NOT NULL, learning_type nvarchar(1) NOT NULL, event_id nvarchar(15) NOT NULL, original_status int, original_substatus nvarchar(85), resultant_status int NOT NULL, resultant_substatus nvarchar(85), enrollment_date datetime, start_date datetime, finish_date datetime, action int, channel int, last_updater_uid nvarchar(85), last_updated datetime NOT NULL, CONSTRAINT PK_TRANS_HISTORY PRIMARY KEY (transcript_history_id))
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'transcript_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.transcript_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'transcript_history_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Primary key';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'transcript_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.transcript_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'transcript_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Transcript ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'transcript_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.transcript_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'user_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'User ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'transcript_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.transcript_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'learning_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Learning ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'transcript_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.transcript_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'learning_type'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Learning type';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'transcript_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.transcript_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'event_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Event (Session) ID that the learner has enrolled into';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'transcript_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.transcript_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'original_status'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Resultant student status of the transcript';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'transcript_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.transcript_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'original_substatus'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Resultant student sub-status of the transcript';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'transcript_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.transcript_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'resultant_status'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Resultant student status of the transcript';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'transcript_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.transcript_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'resultant_substatus'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Resultant student sub-status of the transcript';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'transcript_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.transcript_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'enrollment_date'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Resultant enrollment date of the updated transcript';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'transcript_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.transcript_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'start_date'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Resultant start date of the updated transcript';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'transcript_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.transcript_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'finish_date'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Resultant completion date of the updated transcript';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'transcript_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.transcript_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'action'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Code of action recorded';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'transcript_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.transcript_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'channel'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Code of channel recorded';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'transcript_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.transcript_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_updater_uid'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'UID of change maker';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'transcript_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.transcript_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_updated'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'System datetime of transcript change being recorded';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

CREATE NONCLUSTERED INDEX NUK_TRAN_HIST_TRANSCRIPTID ON transcript_history(transcript_id)
GO

CREATE NONCLUSTERED INDEX NUK_TRAN_HIST_LID_SID ON transcript_history(learning_id, event_id)
GO

CREATE NONCLUSTERED INDEX NUK_TRAN_HIST_LAST_UPDATE ON transcript_history(last_updated)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20170904-ny-1', 'nelson.yip', 'nschema/132.changeLog.xml', GETDATE(), 735, '8:7debf2c5b79e9e787664a80c72ebc1da', 'createTable tableName=transcript_history; createIndex indexName=NUK_TRAN_HIST_TRANSCRIPTID, tableName=transcript_history; createIndex indexName=NUK_TRAN_HIST_LID_SID, tableName=transcript_history; createIndex indexName=NUK_TRAN_HIST_LAST_UPDATE, t...', '[PD-7678] Introduce a Transcript History/Audit Trail', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/132.changeLog.xml::20170906-if-1::ivan.fung
-- [PD-7541] Store the latest setting
ALTER TABLE code_training_resource ADD pre_processing_time int
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'code_training_resource'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.code_training_resource'; DECLARE @ColumnName SYSNAME set @ColumnName = N'pre_processing_time'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Pre Processig Time';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

ALTER TABLE code_training_resource ADD post_processing_time int
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'code_training_resource'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.code_training_resource'; DECLARE @ColumnName SYSNAME set @ColumnName = N'post_processing_time'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Post Processig Time';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20170906-if-1', 'ivan.fung', 'nschema/132.changeLog.xml', GETDATE(), 736, '8:f5cce62696f6c827abaa14512bec3880', 'addColumn tableName=code_training_resource; addColumn tableName=code_training_resource', '[PD-7541] Store the latest setting', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/132.changeLog.xml::20170906-if-2::ivan.fung
-- [PD-7541] Existing resource processing time default to zero
UPDATE code_training_resource SET post_processing_time = '0', pre_processing_time = '0'
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20170906-if-2', 'ivan.fung', 'nschema/132.changeLog.xml', GETDATE(), 737, '8:27b7942dddcede9f375422065b165681', 'update tableName=code_training_resource', '[PD-7541] Existing resource processing time default to zero', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/132.changeLog.xml::20170906-if-3::ivan.fung
-- [PD-7541] Add not null constraint
ALTER TABLE code_training_resource ALTER COLUMN pre_processing_time int NOT NULL
GO

ALTER TABLE code_training_resource ALTER COLUMN post_processing_time int NOT NULL
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20170906-if-3', 'ivan.fung', 'nschema/132.changeLog.xml', GETDATE(), 738, '8:405ccc1d70c881a57bf46b31230a3df8', 'addNotNullConstraint columnName=pre_processing_time, tableName=code_training_resource; addNotNullConstraint columnName=post_processing_time, tableName=code_training_resource', '[PD-7541] Add not null constraint', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/132.changeLog.xml::20170906-if-4::ivan.fung
-- [PD-7541] Store the booking time setting
ALTER TABLE training_resource_reservation ADD pre_processing_time int
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'training_resource_reservation'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.training_resource_reservation'; DECLARE @ColumnName SYSNAME set @ColumnName = N'pre_processing_time'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Pre Processig Time';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

ALTER TABLE training_resource_reservation ADD post_processing_time int
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'training_resource_reservation'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.training_resource_reservation'; DECLARE @ColumnName SYSNAME set @ColumnName = N'post_processing_time'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Post Processig Time';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20170906-if-4', 'ivan.fung', 'nschema/132.changeLog.xml', GETDATE(), 739, '8:6f37909721dcbbccc4d93cc1419c221a', 'addColumn tableName=training_resource_reservation; addColumn tableName=training_resource_reservation', '[PD-7541] Store the booking time setting', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/132.changeLog.xml::20170906-if-5::ivan.fung
-- [PD-7541] Existing bookings processing time defaults to zero
UPDATE training_resource_reservation SET post_processing_time = '0', pre_processing_time = '0'
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20170906-if-5', 'ivan.fung', 'nschema/132.changeLog.xml', GETDATE(), 740, '8:487066928463aee6bfa651c85cf90946', 'update tableName=training_resource_reservation', '[PD-7541] Existing bookings processing time defaults to zero', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/132.changeLog.xml::20170906-if-6::ivan.fung
-- [PD-7541] Add not null constraint
ALTER TABLE training_resource_reservation ALTER COLUMN pre_processing_time int NOT NULL
GO

ALTER TABLE training_resource_reservation ALTER COLUMN post_processing_time int NOT NULL
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20170906-if-6', 'ivan.fung', 'nschema/132.changeLog.xml', GETDATE(), 741, '8:baf211616cee0e68e05f8d81ca63b8e1', 'addNotNullConstraint columnName=pre_processing_time, tableName=training_resource_reservation; addNotNullConstraint columnName=post_processing_time, tableName=training_resource_reservation', '[PD-7541] Add not null constraint', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/132.changeLog.xml::20170921-yc-1::yanfang.cui
-- [PD-7538] Class Resource Facility Assignment
ALTER TABLE code_training_resource ADD facility_id nvarchar(15)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'code_training_resource'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.code_training_resource'; DECLARE @ColumnName SYSNAME set @ColumnName = N'facility_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Facility Id';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20170921-yc-1', 'yanfang.cui', 'nschema/132.changeLog.xml', GETDATE(), 742, '8:bcf4854dcf0b31afc34ab96a367ee65f', 'addColumn tableName=code_training_resource', '[PD-7538] Class Resource Facility Assignment', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/132.changeLog.xml::20170922-sc-1::shu.cui
-- [PD-7483] Generate xAPI statement when a user completes e-learning/exam
ALTER TABLE tincan_statement ALTER COLUMN asserted_by nvarchar(85) NULL
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20170922-sc-1', 'shu.cui', 'nschema/132.changeLog.xml', GETDATE(), 743, '8:73f0bc2a88486943d741993dac3071ff', 'dropNotNullConstraint columnName=asserted_by, tableName=tincan_statement', '[PD-7483] Generate xAPI statement when a user completes e-learning/exam', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/132.changeLog.xml::20170922-tc-1::tommy.chu
-- [PD-7386] Allow Session Transfer for participants and reviewers
ALTER TABLE course ADD allow_session_transfer nvarchar(1) CONSTRAINT DF_course_allow_session_transfer DEFAULT 'N' NOT NULL
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'course'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.course'; DECLARE @ColumnName SYSNAME set @ColumnName = N'allow_session_transfer'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Flag to indicate session tranfer for participants and reviewers is allowed';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20170922-tc-1', 'tommy.chu', 'nschema/132.changeLog.xml', GETDATE(), 744, '8:ad4da1e470a9c6f723ec04a586b30525', 'addColumn tableName=course', '[PD-7386] Allow Session Transfer for participants and reviewers', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/132.changeLog.xml::20170925-tc-1::tommy.chu
-- [PD-7492] Add support for transcript history reporting to Report Wizard
create view session_vw as 
				SELECT        courseid as learning_id, eventid as event_id, session_title as session_title, session_code as session_code
					FROM            cschedule
				UNION ALL
				SELECT        currid as learning_id, sessionid as event_id, session_title as session_title, sessionid as session_code
					FROM            sessiondetail
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20170925-tc-1', 'tommy.chu', 'nschema/132.changeLog.xml', GETDATE(), 745, '8:70fd26aaf35945e5a15ed69c5cc58190', 'sql; sql; sql', '[PD-7492] Add support for transcript history reporting to Report Wizard', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/132.changeLog.xml::20170925-kl-1::kam.lee
-- [PD-7474] Generate xAPI statement when a user enrolls onto a program or module
ALTER TABLE transcript ADD registration char(36)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'transcript'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.transcript'; DECLARE @ColumnName SYSNAME set @ColumnName = N'registration'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Id Of Enrollement For Tincan Statement';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20170925-kl-1', 'kam.lee', 'nschema/132.changeLog.xml', GETDATE(), 746, '8:f09075c484c2f351c636508c1d8913a9', 'addColumn tableName=transcript', '[PD-7474] Generate xAPI statement when a user enrolls onto a program or module', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/132.changeLog.xml::20170922-ny-1::nelson.yip
-- [PD-7387] Transfer user to Prompt User to Select session when dropping from waitlist
ALTER TABLE cschedule ADD transfer_dropped_to_session nvarchar(15)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'cschedule'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.cschedule'; DECLARE @ColumnName SYSNAME set @ColumnName = N'transfer_dropped_to_session'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Event ID of the target session to transfer to upon dropping from waitlist';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DROP VIEW cschedule_vw
GO

CREATE VIEW cschedule_vw AS SELECT
				cschedule.*,      	
				(select count(*)
				 from transcript 
				 where transcript.eventid = cschedule.eventid 
				 and transcript.studentstatus in (select studentstatus from code_enroll_cnt_method where method = cschedule.enroll_cnt_method)) nregistered	
			FROM cschedule
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20170922-ny-1', 'nelson.yip', 'nschema/132.changeLog.xml', GETDATE(), 747, '8:43e12be71ebdfc676d333e92262234f5', 'addColumn tableName=cschedule; dropView viewName=cschedule_vw; createView viewName=cschedule_vw', '[PD-7387] Transfer user to Prompt User to Select session when dropping from waitlist', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/132.changeLog.xml::20171006-if-1::ivan.fung
-- [PD-7713] Class Resource Schedule in Report Wizard
CREATE VIEW training_res_reservation_vw AS SELECT
			trr.resource_id,
			CASE 
				WHEN (trr.eventid IS NOT NULL AND trr.sessionid IS NOT NULL) THEN
					lo.title
				ELSE 
					trr.title 
				END title,
			trr.startdate,
			trr.finishdate,
			CASE 
				WHEN (trr.eventid IS NOT NULL AND trr.sessionid IS NOT NULL) THEN
					lo.title + ' (' + lo.display_learning_id + '), ' + ISNULL(cs.session_title, '') + ' (' + cs.session_code + ')' + 
					CASE 
						WHEN (mss.facilityid <> '_none') THEN
							', ' + f.location + ' (' + f.facility_code + '), ' + tc.training_center_name
						ELSE
							''
						END
				ELSE 
					trr.comments 
				END description,
			trr.qty,
			(trr.startdate - trr.pre_processing_time) pre_processing_startdate,
			(trr.finishdate + trr.post_processing_time) post_processing_finishdate
			FROM training_resource_reservation trr
			LEFT JOIN module_session_schedule mss ON (trr.sessionid = mss.eventid AND trr.eventid = mss.sessionid)
			LEFT JOIN cschedule cs ON mss.sessionid = cs.eventid
			LEFT JOIN learningObject lo ON cs.courseid = lo.learningid
			LEFT JOIN facilities f ON mss.facilityid = f.facilityid 
			LEFT JOIN code_training_center tc ON tc.training_center_id = f.training_center_id
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20171006-if-1', 'ivan.fung', 'nschema/132.changeLog.xml', GETDATE(), 748, '8:27f633762aef62b7f27e4d92d8be44bf', 'createView viewName=training_res_reservation_vw', '[PD-7713] Class Resource Schedule in Report Wizard', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/132.changeLog.xml::20171009-js-1::janice.sung
-- [PD-7935] Block exam review outside allowable IP addresses
ALTER TABLE mastertest ADD restrict_ip_participants char(1) CONSTRAINT DF_mastertest_restrict_ip_participants DEFAULT 'N' NOT NULL
GO

ALTER TABLE mastertest ADD restrict_ip_reviewers char(1) CONSTRAINT DF_mastertest_restrict_ip_reviewers DEFAULT 'N' NOT NULL
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'mastertest'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.mastertest'; DECLARE @ColumnName SYSNAME set @ColumnName = N'restrict_ip_participants'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Extend IP address range restriction to participants';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'mastertest'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.mastertest'; DECLARE @ColumnName SYSNAME set @ColumnName = N'restrict_ip_reviewers'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Extend IP address range restriction to reviewers';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20171009-js-1', 'janice.sung', 'nschema/132.changeLog.xml', GETDATE(), 749, '8:f0e4e18fd77cb87160828f60f3dd1e7b', 'addColumn tableName=mastertest', '[PD-7935] Block exam review outside allowable IP addresses', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/132.changeLog.xml::20171011-if-1::ivan.fung
-- [PD-7537] Class Resource Attribute Display Areas
UPDATE dynamic_attribute SET display_areas = 'FV' WHERE category = 'CR' and type <> 'S'
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20171011-if-1', 'ivan.fung', 'nschema/132.changeLog.xml', GETDATE(), 750, '8:16b18c0393b3d0328d319758eb6f420b', 'update tableName=dynamic_attribute', '[PD-7537] Class Resource Attribute Display Areas', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/132.changeLog.xml::20171012-ny-1::nelson.yip
-- [PD-7577] Reserve seats for PENDING APPROVAL
ALTER TABLE code_enroll_cnt_method ADD consider_reserve_only nvarchar(1) CONSTRAINT DF_code_enroll_cnt_method_consider_reserve_only DEFAULT 'N' NOT NULL
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'code_enroll_cnt_method'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.code_enroll_cnt_method'; DECLARE @ColumnName SYSNAME set @ColumnName = N'consider_reserve_only'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Should count only if transcript.reserve_seat is Y';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

ALTER TABLE transcript ADD reserve_seat nvarchar(1) CONSTRAINT DF_transcript_reserve_seat DEFAULT 'Y' NOT NULL
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'transcript'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.transcript'; DECLARE @ColumnName SYSNAME set @ColumnName = N'reserve_seat'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Flag to indicate whether a seat should be reserved';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

UPDATE code_enroll_cnt_method SET consider_reserve_only =  'Y' where studentstatus=7
GO

CREATE VIEW cschedule_nreserved_vw AS SELECT c.courseid, c.eventid, 
			       SUM(CASE WHEN t.studentstatus IS NULL THEN 0
					    WHEN m.consider_reserve_only='N' THEN 1
					    WHEN (m.consider_reserve_only='Y' AND t.reserve_seat ='Y') THEN 1
					    ELSE 0 END) nreserved
			FROM cschedule c
				INNER JOIN code_enroll_cnt_method m ON m.method = c.enroll_cnt_method
				LEFT JOIN transcript t ON t.eventid = c.eventid AND t.studentstatus = m.studentstatus
				GROUP BY c.courseid, c.eventid
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20171012-ny-1', 'nelson.yip', 'nschema/132.changeLog.xml', GETDATE(), 751, '8:2f0823f570bbbec62a920c4a83f54ab1', 'addColumn tableName=code_enroll_cnt_method; addColumn tableName=transcript; sql; createView viewName=cschedule_nreserved_vw', '[PD-7577] Reserve seats for PENDING APPROVAL', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/132.changeLog.xml::20171016-js-1::janice.sung
-- This table stores information about the user merge
CREATE TABLE user_merge_history (id nvarchar(85) NOT NULL, merge_time datetime NOT NULL, actor_currentpid nvarchar(85) NOT NULL, source_user_meta_id nvarchar(85) NOT NULL, source_currentpid nvarchar(85) NOT NULL, source_familyname nvarchar(85) NOT NULL, source_givenname nvarchar(85) NOT NULL, source_middlename nvarchar(85), target_user_meta_id nvarchar(85) NOT NULL, target_currentpid nvarchar(85) NOT NULL, target_familyname nvarchar(85) NOT NULL, target_givenname nvarchar(85) NOT NULL, target_middlename nvarchar(85), CONSTRAINT PK_USER_MERGE_HISTORY PRIMARY KEY (id))
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_merge_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_merge_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Primary key';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_merge_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_merge_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'merge_time'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'The time and date of the user merge';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_merge_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_merge_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'actor_currentpid'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Current PID of the actor';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_merge_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_merge_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'source_user_meta_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'User Meta ID of source user';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_merge_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_merge_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'source_currentpid'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Current PID of source user';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_merge_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_merge_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'source_familyname'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Family name of source user';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_merge_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_merge_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'source_givenname'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Given name of source user';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_merge_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_merge_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'source_middlename'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Middle name of source user';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_merge_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_merge_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'target_user_meta_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'User Meta ID of target user';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_merge_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_merge_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'target_currentpid'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Current PID of target user';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_merge_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_merge_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'target_familyname'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Family name of target user';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_merge_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_merge_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'target_givenname'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Given name of target user';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_merge_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_merge_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'target_middlename'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Middle name of target user';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20171016-js-1', 'janice.sung', 'nschema/132.changeLog.xml', GETDATE(), 752, '8:0b061f76ca4778ac2b0e538dab76d6bc', 'createTable tableName=user_merge_history', 'This table stores information about the user merge', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/132.changeLog.xml::20171017-wp-1::william.puk
-- [PD-7631] Drop Not Null constraint of non-nullable description column of MYSQL and MSSQL.
ALTER TABLE code_training_resource ALTER COLUMN description nvarchar(1000) NULL
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20171017-wp-1', 'william.puk', 'nschema/132.changeLog.xml', GETDATE(), 753, '8:59b19d547590d9c0643e7afdac627907', 'dropNotNullConstraint columnName=description, tableName=code_training_resource', '[PD-7631] Drop Not Null constraint of non-nullable description column of MYSQL and MSSQL.', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/132.changeLog.xml::20171017-wp-2::william.puk
-- [PD-7631] Create a new text column for WYSIWYG editor enabled description, and migrate old data to it.
exec sp_rename 'code_training_resource.description', 'description_bak'
GO

ALTER TABLE code_training_resource ADD description nvarchar (max)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'code_training_resource'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.code_training_resource'; DECLARE @ColumnName SYSNAME set @ColumnName = N'description'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Description of the resource';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

UPDATE code_training_resource SET description=description_bak
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20171017-wp-2', 'william.puk', 'nschema/132.changeLog.xml', GETDATE(), 754, '8:5bf6f9062899033e2d4b4fd151ca687f', 'renameColumn newColumnName=description_bak, oldColumnName=description, tableName=code_training_resource; addColumn tableName=code_training_resource; sql', '[PD-7631] Create a new text column for WYSIWYG editor enabled description, and migrate old data to it.', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/132.changeLog.xml::20171018-wp-1::william.puk
-- [PD-7715] Create a new column to store the corresponding resource_id of each of the migrated Demo Units
ALTER TABLE demo_unit ADD mapped_resource_id nvarchar(15)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'demo_unit'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.demo_unit'; DECLARE @ColumnName SYSNAME set @ColumnName = N'mapped_resource_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'The mapped resource id in code_training_resource table, after Demo Unit migration.';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20171018-wp-1', 'william.puk', 'nschema/132.changeLog.xml', GETDATE(), 755, '8:d4342770a2b043de102e92e9b2013661', 'addColumn tableName=demo_unit', '[PD-7715] Create a new column to store the corresponding resource_id of each of the migrated Demo Units', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/140.changeLog.xml::24Oct2017-sg-1::shravan.gurrala
UPDATE ekpversion SET dblevel = 140, splevel = 0
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('24Oct2017-sg-1', 'shravan.gurrala', 'nschema/140.changeLog.xml', GETDATE(), 756, '8:3b2dd549db2594386a37f92e969ee17c', 'update tableName=ekpversion', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/140.changeLog.xml::20171121-if-1::ivan.fung
-- [PD-7540] Recommended Class Resources
CREATE TABLE class_resource_recommend (recommend_id nvarchar(85) NOT NULL, learning_id nvarchar(85) NOT NULL, resource_id nvarchar(15) NOT NULL, CONSTRAINT PK_CLS_RES_RECOMMEND PRIMARY KEY (recommend_id))
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'class_resource_recommend'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.class_resource_recommend'; DECLARE @ColumnName SYSNAME set @ColumnName = N'recommend_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Primary key';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'class_resource_recommend'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.class_resource_recommend'; DECLARE @ColumnName SYSNAME set @ColumnName = N'learning_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Learning Object ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'class_resource_recommend'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.class_resource_recommend'; DECLARE @ColumnName SYSNAME set @ColumnName = N'resource_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Class Resource ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

ALTER TABLE class_resource_recommend ADD CONSTRAINT UK_CLS_RES_LEARN_RES UNIQUE (learning_id, resource_id)
GO

ALTER TABLE class_resource_recommend ADD CONSTRAINT FK_CLS_RES_LEARN_ID FOREIGN KEY (learning_id) REFERENCES learningObject (learningid)
GO

ALTER TABLE class_resource_recommend ADD CONSTRAINT FK_CLS_RES_RES_ID FOREIGN KEY (resource_id) REFERENCES code_training_resource (resource_id)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20171121-if-1', 'ivan.fung', 'nschema/140.changeLog.xml', GETDATE(), 757, '8:8994a9266afc319f89f7eb0dd2ffdd4e', 'createTable tableName=class_resource_recommend; addUniqueConstraint constraintName=UK_CLS_RES_LEARN_RES, tableName=class_resource_recommend; addForeignKeyConstraint baseTableName=class_resource_recommend, constraintName=FK_CLS_RES_LEARN_ID, refere...', '[PD-7540] Recommended Class Resources', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/140.changeLog.xml::20171208-wp-1::william.puk
-- [PD-8040] Adobe Connect Course Titles Exceed Database Field Length
ALTER TABLE vc_adobe_connect_trng ALTER COLUMN ac_title nvarchar(600)
GO

ALTER TABLE AICC_interactions ALTER COLUMN response_value nvarchar(1000)
GO

ALTER TABLE AICC_interactions ALTER COLUMN student_response nvarchar(1000)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20171208-wp-1', 'william.puk', 'nschema/140.changeLog.xml', GETDATE(), 758, '8:c88a8e1b9535d2e15a444b3b5029e16f', 'modifyDataType columnName=ac_title, tableName=vc_adobe_connect_trng; modifyDataType columnName=response_value, tableName=AICC_interactions; modifyDataType columnName=student_response, tableName=AICC_interactions', '[PD-8040] Adobe Connect Course Titles Exceed Database Field Length', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/140.changeLog.xml::20171214-gl-1::garbo.lim
-- [PD-8633] Cache Rebuild
ALTER TABLE ekpversion ADD current_version nvarchar(100)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'ekpversion'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.ekpversion'; DECLARE @ColumnName SYSNAME set @ColumnName = N'current_version'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Stores the current NTS version including build number';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20171214-gl-1', 'garbo.lim', 'nschema/140.changeLog.xml', GETDATE(), 759, '8:e2c8be926855cd1f7fbc856e4a4da5cf', 'addColumn tableName=ekpversion', '[PD-8633] Cache Rebuild', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/140.changeLog.xml::20171220-js-1::janice.sung
-- [PD-8741] Generate client unique key for Solr Collections
ALTER TABLE ekpversion ADD client_unique_key nvarchar(100)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'ekpversion'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.ekpversion'; DECLARE @ColumnName SYSNAME set @ColumnName = N'client_unique_key'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Stores the generated client unique key';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20171220-js-1', 'janice.sung', 'nschema/140.changeLog.xml', GETDATE(), 760, '8:c4090f1488957ff42771497589da5ee4', 'addColumn tableName=ekpversion', '[PD-8741] Generate client unique key for Solr Collections', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/140.changeLog.xml::20180117-sc-1::starry.chan
-- BUG#PD-8879 Learning path is extremely slow
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = 'NUK_COURSE_COMP_EXP')
			DROP INDEX NUK_COURSE_COMP_EXP ON course_competency_exp
GO

if exists (
				SELECT  *
				FROM (SELECT CAST(serverproperty('ProductVersion') AS nvarchar) ver) as t
				where CAST(SUBSTRING(ver, 1, CHARINDEX('.', ver) - 1) as int) >= 9
			)
			CREATE NONCLUSTERED INDEX NUK_COURSE_COMP_EXP
			ON course_competency_exp (user_id)
			INCLUDE (id, course_id, competency_id, expiry_date, complete_date)
GO

IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = 'NUK_COURSE_COMP_EXP_TRAN')
			DROP INDEX NUK_COURSE_COMP_EXP_TRAN ON course_competency_exp_tran
GO

if exists (
				SELECT  *
				FROM (SELECT CAST(serverproperty('ProductVersion') AS nvarchar) ver) as t
				where CAST(SUBSTRING(ver, 1, CHARINDEX('.', ver) - 1) as int) >= 9
			)
			CREATE NONCLUSTERED INDEX NUK_COURSE_COMP_EXP_TRAN
			ON course_competency_exp_tran (transcript_id)
			INCLUDE (course_comp_exp_id)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20180117-sc-1', 'starry.chan', 'nschema/140.changeLog.xml', GETDATE(), 761, '8:b567b932782efa6d7a28d8e8c365cf88', 'sql; sql; sql; sql', 'BUG#PD-8879 Learning path is extremely slow', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/140.changeLog.xml::20180130-kl-2::kam.lee
CREATE NONCLUSTERED INDEX NUK_TRAN_SUBT_TARGET_TRAN_ID
   				ON submod_tran_subt (target_tran_id)
   				INCLUDE (substitute_tran_id, substitute_learning_id)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20180130-kl-2', 'kam.lee', 'nschema/140.changeLog.xml', GETDATE(), 762, '8:34a0026fe34c065ea61d6e7ed7048acc', 'sql', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/140.changeLog.xml::20180305-wp-1::william.puk
-- [PD-9027] Handling of Background Task Queues in Multi-Node Environment
ALTER TABLE pending_mail ADD bcc_users nvarchar (max)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'pending_mail'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.pending_mail'; DECLARE @ColumnName SYSNAME set @ColumnName = N'bcc_users'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'A list of Bcc recipients';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20180305-wp-1', 'william.puk', 'nschema/140.changeLog.xml', GETDATE(), 763, '8:d42aa81a9575e70efa18845107b9de70', 'addColumn tableName=pending_mail', '[PD-9027] Handling of Background Task Queues in Multi-Node Environment', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/140.changeLog.xml::20180306-kk-1::Krupa.Kamat
-- GDPR Story
CREATE NONCLUSTERED INDEX NUK_ACCAUDIT_USERID ON accessAuditTrail(userid)
GO

CREATE NONCLUSTERED INDEX NUK_ACC_CREATOR ON accounts(creator)
GO

CREATE NONCLUSTERED INDEX NUK_ACNT_LASTUPDATID ON accounts(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_ADIT_ATMT_GRANTID ON additional_attempts(grantor_id)
GO

CREATE NONCLUSTERED INDEX NUK_ADITATMT_TRANSID ON additional_attempts(transcript_id)
GO

CREATE NONCLUSTERED INDEX NUK_AICC_AU_LASTUPDATID ON AICC_au(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_AICCCOREVEN_LSTUPDATID ON AICC_Core_Vendor(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_AICCDES_LSTUPDATID ON AICC_des(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_AICCLNCHOPTS_LASTUPDATID ON AICC_launch_options(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_ANALYUSE_USERID ON analytics_user(nts_user_id)
GO

CREATE NONCLUSTERED INDEX NUK_ANSDROP_TESTINSTID ON answer_drag_and_drop(test_instance_id)
GO

CREATE NONCLUSTERED INDEX NUK_ANS_HST_TESTINSTID ON answer_hotspot(test_instance_id)
GO

CREATE NONCLUSTERED INDEX NUK_APPR_USERID ON appraisal(userid)
GO

CREATE NONCLUSTERED INDEX NUK_APTEMP_CREATUSERID ON appraisal_template(created_user_id)
GO

CREATE NONCLUSTERED INDEX NUK_APTEMPSPE_APPID ON appraisal_template(specified_super_appraiser_id)
GO

CREATE NONCLUSTERED INDEX NUK_APPRCARDEV_APPRA_ID ON appraisal_u_career_dev(appraisal_id)
GO

CREATE NONCLUSTERED INDEX NUK_APPRA_COM_APPRA_ID ON appraisal_u_competency(appraisal_id)
GO

CREATE NONCLUSTERED INDEX NUK_APPRA_DIM_APPR_ID ON appraisal_u_dimension(appraisal_id)
GO

CREATE NONCLUSTERED INDEX NUK_APAFRTEXT_APPRA_ID ON appraisal_u_free_text(appraisal_id)
GO

CREATE NONCLUSTERED INDEX NUK_APPRPAST_OBJ_APPR_ID ON appraisal_u_past_objective(appraisal_id)
GO

CREATE NONCLUSTERED INDEX NUK_APPROFF_APPR_ID ON appraisal_u_sign_off(appraisal_id)
GO

CREATE NONCLUSTERED INDEX NUK_APPRSING_APPR_ID ON appraisal_u_single_choice(appraisal_id)
GO

CREATE NONCLUSTERED INDEX NUK_APPRSUCPLAN_APPR_ID ON appraisal_u_succession_plan(appraisal_id)
GO

CREATE NONCLUSTERED INDEX NUK_APPRQUE_LASTUPDATUID ON approval_queue(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_APPRQUESTEP_LASTUPDATUID ON approval_queue_step(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_ART_FROMUSEID ON article(fromuserid)
GO

CREATE NONCLUSTERED INDEX NUK_ART_LAST_UPDAT_UID ON article(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_ASSOORGS_USERID ON associated_orgs(userid)
GO

CREATE NONCLUSTERED INDEX NUK_ATUDIT_USERID ON attendance_audit(userid)
GO

CREATE NONCLUSTERED INDEX NUK_ATAUDIT_INSTRUCTOR ON attendance_audit(instructor)
GO

CREATE NONCLUSTERED INDEX [NUK_AUDI_LAST_UPDAT   _UID] ON audience(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_AUDLOG_USERID ON auditlogins(userid)
GO

CREATE NONCLUSTERED INDEX NUK_AUDOBJ_USERID ON auditobjects(userid)
GO

CREATE NONCLUSTERED INDEX NUK_AUT_LASTUPDATUID ON autoenroll(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_AUTENRTRA_USERID ON autoenroll_trace(userid)
GO

CREATE NONCLUSTERED INDEX NUK_BATCHREPORT_USERID ON batchreport(userid)
GO

CREATE NONCLUSTERED INDEX NUK_BULL_USERID ON bulletin(fromuserid)
GO

CREATE NONCLUSTERED INDEX NUK_CERTREN_LASTUPDATUID ON cert_renewal(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_CERTSCH_LASTUPDATUID ON cert_schedule(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_CERT_LASTUPDATUID ON certifications(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_CERT_CREATUID ON certifications(creator_uid)
GO

CREATE NONCLUSTERED INDEX NUK_CERTUSERS_AWARDBY ON certusers(awardedby)
GO

CREATE NONCLUSTERED INDEX NUK_CERT_LAST_UPDATERUID ON certusers(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_CERT_PEND_USERID ON certusers_pending(userid)
GO

CREATE NONCLUSTERED INDEX NUK_CERT_PEND_AWARBY ON certusers_pending(awardedby)
GO

CREATE NONCLUSTERED INDEX NUK_CERTPEN_LASTUPDATUID ON certusers_pending(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_CHATROOMS_CREATEDBY ON chatrooms(createdby)
GO

CREATE NONCLUSTERED INDEX NUK_CHECK_ITEMCREATID ON checklist_item(creator_id)
GO

CREATE NONCLUSTERED INDEX NUK_CHECK_TEMP_CREATUID ON checklist_template(creator_uid)
GO

CREATE NONCLUSTERED INDEX NUK_CHECKTEMP_LASTUPDATUID ON checklist_template(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_CHECKTEMP_OWNERID ON checklist_template_item(owner_id)
GO

CREATE NONCLUSTERED INDEX NUK_CODECATST_CREATIONUID ON code_catalog_structure(creation_uid)
GO

CREATE NONCLUSTERED INDEX NUK_CODEORGST_CREATUID ON code_orgstructure(creator_uid)
GO

CREATE NONCLUSTERED INDEX NUK_CODE_ORGSTDEF_APPRID ON code_orgstructure(default_approver_id)
GO

CREATE NONCLUSTERED INDEX NUK_COLPRE_ASSIGNID ON column_preset(assignment_id)
GO

CREATE NONCLUSTERED INDEX NUK_COL_PRE_CREATUID ON column_preset(creator_uid)
GO

CREATE NONCLUSTERED INDEX NUK_COMHIST_USERID ON comp_analysis_history_overall(analysis_user_id)
GO

CREATE NONCLUSTERED INDEX NUK_COMAPPR_USER_ID ON comp_approval_queue(user_id)
GO

CREATE NONCLUSTERED INDEX NUK_COMPQUE_APPR_ID ON comp_approval_queue(approver_id)
GO

CREATE NONCLUSTERED INDEX NUK_COMEVALPARTICIP_ID ON comp_assess_participant_eval(participant_id)
GO

CREATE NONCLUSTERED INDEX NUK_COMASSESS_USERID ON comp_assess_user_participant(user_id)
GO

CREATE NONCLUSTERED INDEX NUK_COMPASSE_REVIEWID ON competency_assessment(reviewee_id)
GO

CREATE NONCLUSTERED INDEX NUK_COMPLEV_LASTUPDATUID ON competency_level(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_CONFDEF_SYSUSER ON configDefaults(systemuser)
GO

CREATE NONCLUSTERED INDEX NUK_CONFDEF_SYSAPPR ON configDefaults(systemapprover)
GO

CREATE NONCLUSTERED INDEX NUK_CONITEM_LASTUPDATUID ON ContentItem(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_CONOBJ_OWNERID ON ContentObject(ownerID)
GO

CREATE NONCLUSTERED INDEX NUK_CONORG_OWNERID ON ContentOrganization(ownerID)
GO

CREATE NONCLUSTERED INDEX NUK_CONTORG_LASTUPDATUID ON ContentOrganizationNode(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_CONTORGLAST_ITEMID ON ContentOrganizationNode(itemID)
GO

CREATE NONCLUSTERED INDEX NUK_CONTPACK_OWNERID ON ContentPackage(ownerID)
GO

CREATE NONCLUSTERED INDEX NUK_COUPON_ISSUERID ON coupon(issuerid)
GO

CREATE NONCLUSTERED INDEX NUK_COUPON_HOLDERID ON coupon(holderid)
GO

CREATE NONCLUSTERED INDEX NUK_COU_LAST_UPDAT_UID ON course(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_BUND_LASTUPDATUID ON course_bundle(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_COMP_LASTUPDATUID ON course_competency(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_REVI_LASTUPDATUID ON course_revision(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_SESCOST_LASTUPDATUID ON course_session_cost(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_ACCLEV_LASTUPDATUID ON courseAccessLevel(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_DOWN_LASTUPDATUID ON courseDownloads(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_TEST_LASTUPDATUID ON coursetest(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_CSCH_APPROVERID1 ON cschedule(approverid1)
GO

CREATE NONCLUSTERED INDEX NUK_CSCHE_APPROVERID2 ON cschedule(approverid2)
GO

CREATE NONCLUSTERED INDEX NUK_CURRCOU_APPROVERID1 ON currcourses(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_CURSTAT_USERID ON current_progress_status(userid)
GO

CREATE NONCLUSTERED INDEX NUK_CURRI_APPROVERID1 ON curriculum(approverid1)
GO

CREATE NONCLUSTERED INDEX NUK_CURRI_APPROVERID2 ON curriculum(approverid2)
GO

CREATE NONCLUSTERED INDEX NUK_CUSCOUPOL_LASTUPDATUID ON custom_course_policy(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_DASH_CHARTTABID ON dashboard_tab_chart(tab_id)
GO

CREATE NONCLUSTERED INDEX NUK_DASHB_TABS_USERID ON dashboard_tabs(userid)
GO

CREATE NONCLUSTERED INDEX NUK_LOADFILES_USERID ON dataloaderfiles(userid)
GO

CREATE NONCLUSTERED INDEX NUK_DRAG_LAST_UPDAT_UID ON draggable(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_ESIGN_CONTUSERID ON e_signature_context(userid)
GO

CREATE NONCLUSTERED INDEX NUK_EKPREV_CREATEDBY ON ekpfiles_revision(created_by)
GO

CREATE NONCLUSTERED INDEX NUK_EM_PROFSPEC_USERID ON email_profile(specific_user_id)
GO

CREATE NONCLUSTERED INDEX NUK_EMAILPROF_SENDERID ON email_profile(sender_id)
GO

CREATE NONCLUSTERED INDEX NUK_ENRPOL_LASTUPDATUID ON enrollment_policy(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_ENRPOLSTEP_LASTUPDATUID ON enrollment_policy_step(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_EQU_RULE_LASTUPDATUID ON equivalency_rules(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_EQU_RULES_CREATED_BY ON equivalency_rules(created_by)
GO

CREATE NONCLUSTERED INDEX NUK_EVAL_USERID ON evaluation(userid)
GO

CREATE NONCLUSTERED INDEX NUK_EVALSUM_LASTUPDATERUID ON evaluation_summary(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_EX_Q_APPR_USERID ON ex_q_approval(user_id)
GO

CREATE NONCLUSTERED INDEX NUK_EXA_COM_LASTUPDAT_ID ON exam_comment(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_EXA_WORK_LASTUPDATUID ON exam_workflow(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_EXA_WORKS_LASTUPDATUID ON exam_workflow_step(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_EXSERLOG_CREATUID ON exchange_server_login(creator_uid)
GO

CREATE NONCLUSTERED INDEX NUK_EXT_EMAIL_SENDER_ID ON extern_mail(sender_id)
GO

CREATE NONCLUSTERED INDEX NUK_EXTEMAIL_REC_EMAIL ON extern_mail(receiver_email)
GO

CREATE NONCLUSTERED INDEX NUK_FACI_CREATOR_UID ON facilities(creator_uid)
GO

CREATE NONCLUSTERED INDEX NUK_FACI_RES_USERID ON facility_reservation(userid)
GO

CREATE NONCLUSTERED INDEX NUK_FIL_TEMP_CREAT_UID ON filter_templates(creator_uid)
GO

CREATE NONCLUSTERED INDEX NUK_FORUM_FROMUSERID ON forum(fromuserid)
GO

CREATE NONCLUSTERED INDEX NUK_FORUM_SUBS_USERID ON forum_subscription(userid)
GO

CREATE NONCLUSTERED INDEX NUK_ABSLAUN_LASTUPDATUID ON get_abstract_launcher(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_GLOENG_LASTUPDATUID ON globalenglish_launcher(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_GOAL_DEV_CREAT_BY ON goal_development(created_by)
GO

CREATE NONCLUSTERED INDEX NUK_GOAL_PER_CREAT_BY ON goal_personal(created_by)
GO

CREATE NONCLUSTERED INDEX NUK_GOAL_TRA_CREAT_BY ON goal_tracking(created_by)
GO

CREATE NONCLUSTERED INDEX NUK_HOME_FILE_OWNERID ON homework_file(ownerid)
GO

CREATE NONCLUSTERED INDEX NUK_HOMEFILETO_USERID ON homework_file(to_userid)
GO

CREATE NONCLUSTERED INDEX NUK_HOTS_LASTUPDATUID ON hotspot(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_ICOMM_PREPAREDBY ON iComment(preparedby)
GO

CREATE NONCLUSTERED INDEX NUK_ICOMM_TRANSID ON iComment(transcriptid)
GO

CREATE NONCLUSTERED INDEX NUK_INDICOMP_CREATOR_UID ON individual_competency(creator_uid)
GO

CREATE NONCLUSTERED INDEX NUK_JOBPROF_CREATOR_UID ON job_profile(creator_uid)
GO

CREATE NONCLUSTERED INDEX NUK_JOB_PROF_OWNER_ID ON job_profile(owner_id)
GO

CREATE NONCLUSTERED INDEX NUK_JOBPROFCOMPDTL_USER_ID ON job_profile_comp_stats_dtl(user_id)
GO

CREATE NONCLUSTERED INDEX NUK_JOBPROFCOMP_LASTUPDATID ON job_profile_competency(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_JOB_PROF_AENR_LASTUPDATID ON jobprofile_autoenroll(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_KNOWCENOPT_LASTUPDATID ON knowledgecenteroptions(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_LANGBUN_LASTUPDAT_ID ON language_bundle(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_LANG_CUSSTRLASTUPDATID ON language_custom_string(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_LEAROBJ_CREATOR_UID ON learningObject(creator_uid)
GO

CREATE NONCLUSTERED INDEX NUK_LO_LASTUPDATUID ON lo_attribute(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_LO_OPTPAYIT_LASTUPDATUID ON lo_opt_pay_items(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_LOCOST_LASTUPDATUID ON locosts(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_LOGDOMSYS_USERID ON logical_domain(system_userid)
GO

CREATE NONCLUSTERED INDEX NUK_LOGDOMSYS_APPROVID ON logical_domain(system_approverid)
GO

CREATE NONCLUSTERED INDEX NUK_LOGDOMCREAT_UID ON logical_domain(creator_uid)
GO

CREATE NONCLUSTERED INDEX NUK_LOGDOMCRIT_LASTUPDATUID ON logical_domain_criteria(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_LP_SESCOST_LASTUPDATUID ON lp_session_cost(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_MASQUE_LASTUPDATUID ON masterquestion(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_MASEC_LASTUPDATUID ON mastersection(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_MASSECATTR_LASTUPDATUID ON mastersection_attr(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_MASTEST_OWNER ON mastertest(owner)
GO

CREATE NONCLUSTERED INDEX NUK_MASTEST_CREATORUID ON mastertest(creator_uid)
GO

CREATE NONCLUSTERED INDEX NUK_MASTESTPRI_LASTUPDATUID ON mastertest_print(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_MKEPNOD_CREATUSERID ON mekp_node_activation_list(creator_userid)
GO

CREATE NONCLUSTERED INDEX NUK_MES_FROMUSERID ON messages(fromuserid)
GO

CREATE NONCLUSTERED INDEX NUK_MOD_SES_LASTUPDATUID ON module_session_schedule(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_MSGCONTENT_USERID ON msgContent(userid)
GO

CREATE NONCLUSTERED INDEX NUK_MYREPORT_OWNER ON my_report(owner)
GO

CREATE NONCLUSTERED INDEX NUK_NETLAR_LASTUPDATUID ON netassessor_launcher(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_NETPROAUT_LASTUPDATUID ON netg_proxied_authentication(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_OAUTHVER_USER_ID ON oauth_verifier(user_id)
GO

CREATE NONCLUSTERED INDEX NUK_OBJTOP_LASTUPDATUID ON objectives_topics(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_ORGATT_LASTUPDATUID ON org_attribute(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_OTHOBJ_LASTUPDATUID ON otherObjects(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_PAYMENTPAY_USER_ID ON payment(pay_user_id)
GO

CREATE NONCLUSTERED INDEX NUK_PAYMENT_REVIEBY ON payment(reviewed_by)
GO

CREATE NONCLUSTERED INDEX NUK_PEN_MAIL_FORM_USER_ID ON pending_mail(from_user_id)
GO

CREATE NONCLUSTERED INDEX NUK_PERMI_LAST_UPDATER_UID ON permissions(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_PERSONAL_EVENT_USERID ON personal_event(userid)
GO

CREATE NONCLUSTERED INDEX NUK_PREFERENCE_USERID ON preferences(userid)
GO

CREATE NONCLUSTERED INDEX NUK_PREREQ_LASTUPDATUID ON prereq(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_QATTR_LAST_UPDAT_UID ON qattributes(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_QUESTION_OWNER ON question(owner)
GO

CREATE NONCLUSTERED INDEX NUK_QUESTION_WRITER ON question(writer)
GO

CREATE NONCLUSTERED INDEX NUK_QUE_ATTA_OWNER ON question_attachment(owner_id)
GO

CREATE NONCLUSTERED INDEX NUK_QUE_ATTR_LASTUPDATUID ON question_attribute(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_QUE_BUND_LASTUPDATUID ON question_bundle(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_QUES_CHOI_LASTUPDATUID ON question_choices(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_QUE_POOL_USERID ON question_pool_reminder_detail(userid)
GO

CREATE NONCLUSTERED INDEX NUK_QUETYPE_LASTUPDATUID ON question_type_drag_and_drop(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_QUEHST_LASTUPDATUID ON question_type_hotspot(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_QUE1_LASTUPDATUID ON question_type1(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_QUE2_LAST_UPDATER_UID ON question_type2(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_QUE3_LASTUPDATUID ON question_type3(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_QUES4_LASTUPDATUID ON question_type4(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_QUE5_LASTUPDATERUID ON question_type5(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_QUE6_LAST_UPDATER_UID ON question_type6(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_QUE7_LAST_UPDATER_UID ON question_type7(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_QUE8_LAST_UPDATER_UID ON question_type8(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_QUE8ITEM_LASTUPDATUID ON question_type8_item(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_QUE9_LAST_UPDATER_UID ON question_type9(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_RANDS_LAST_UPDAT_UID ON randsection(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_REGEVE_LASTUPDATUID ON registeredevents(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_REPWIZ_OWNER ON report_wizard(owner)
GO

CREATE NONCLUSTERED INDEX NUK_RES_PER_USERID ON resolved_permissions(userid)
GO

CREATE NONCLUSTERED INDEX NUK_RESPERORG_USERID ON resolved_permissions_orgtype(userid)
GO

CREATE NONCLUSTERED INDEX NUK_RES_STR_LASTUPDATUID ON resource_string(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_ROLLUP_LASTUPDATUID ON RollupCondition(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_ROLLUP_LAST_UPDAT_UID ON RollupRule(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_RULE_SET_MEMBERSHIP ON rule_set_membership(userid)
GO

CREATE NONCLUSTERED INDEX NUK_SAFLAU_LASTUPDATUID ON safari_launcher(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_SCHEREP_USERID ON schedule_report_delivery(userid)
GO

CREATE NONCLUSTERED INDEX NUK_SCHE_TASK_USERID ON schedule_task(userid)
GO

CREATE NONCLUSTERED INDEX NUK_SELF_ATT_UPLOADED_BY ON selfaward_attach(uploaded_by)
GO

CREATE NONCLUSTERED INDEX NUK_SEQOBJEM_LASTUPDATUID ON SeqObjectiveMap(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_SEQRULEC_LASTUPDATUID ON SeqRuleCondition(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_SEQOBJE_LASTUPDATUID ON SequenceObjective(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_SEQRULE_LASTUPDATUID ON SequenceRule(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_SEQUEN_LASTUPDATUID ON Sequencing(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_SES_ATTR_LASTUPDAUID ON session_attribute(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_SESCOST_LAST_UPDAT_UID ON session_cost(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_SESDET_APPROVERID1 ON sessiondetail(approverid1)
GO

CREATE NONCLUSTERED INDEX NUK_SESDET_APPROVERID2 ON sessiondetail(approverid2)
GO

CREATE NONCLUSTERED INDEX NUK_SHAFIL_OWNER_ID ON shared_files(owner_id)
GO

CREATE NONCLUSTERED INDEX NUK_SUBTRANS_LEARNID ON submod_tran_subt(learner_id)
GO

CREATE NONCLUSTERED INDEX NUK_SUP_USERID ON supervises(userid)
GO

CREATE NONCLUSTERED INDEX NUK_SURVEY_USERID ON survey(userid)
GO

CREATE NONCLUSTERED INDEX NUK_TREMI_APPROVERID ON task_reminder_log(approver_id)
GO

CREATE NONCLUSTERED INDEX NUK_TASKOFF_LASTUPDATUID ON task_signoff_config(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_TEMPWID_UPDAT_UID ON template_widget_html_preset(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_TINSTA_SES_ID ON tincan_statement(session_id)
GO

CREATE NONCLUSTERED INDEX NUK_TMS_RES_LUPDID ON tms_responsibility_level(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_TMS_SKILL_IMPORT_BY ON tms_skill_dictionary(imported_by)
GO

CREATE NONCLUSTERED INDEX NUK_TOKENTRAN_USERID ON token_transaction(user_id)
GO

CREATE NONCLUSTERED INDEX NUK_TOKENTRAN_TRANSCID ON token_transaction(transcript_id)
GO

CREATE NONCLUSTERED INDEX NUK_TRAI_RES_USERID ON training_resource_reservation(userid)
GO

CREATE NONCLUSTERED INDEX NUK_TRAINPLAN_PREPBY ON trainingPlan(preparedby)
GO

CREATE NONCLUSTERED INDEX NUK_TRANATT_LUPDID ON transcript_attribute(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_TRAN_EQU_USERID ON transcript_equivalent(userid)
GO

CREATE NONCLUSTERED INDEX NUK_TRANS_HIS_USER_ID ON transcript_history(user_id)
GO

CREATE NONCLUSTERED INDEX NUK_TRANSSTAT_LUPDID ON transcript_stat_log(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_TSUBS_LUPDID ON transcript_substatus(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_TSYNC_USERID ON transcript_sync_history(sync_user_id)
GO

CREATE NONCLUSTERED INDEX NUK_TRANS_TRANS_ID ON transcript_sync_history(transcript_id)
GO

CREATE NONCLUSTERED INDEX NUK_USER_ACC_USERID ON user_account_approval_tasks(userid)
GO

CREATE NONCLUSTERED INDEX NUK_USEAPPR_APPID ON user_appraisal(appraiser_id)
GO

CREATE NONCLUSTERED INDEX NUK_USEAPPR_CREAID ON user_appraisal(created_user_id)
GO

CREATE NONCLUSTERED INDEX NUK_USER_APPR_USER_ID ON user_appraisal_change_log(user_id)
GO

CREATE NONCLUSTERED INDEX NUK_USER_COMPUSER_ID ON user_competency(user_id)
GO

CREATE NONCLUSTERED INDEX NUK_US_GROUP_CREATUID ON user_group(creator_uid)
GO

CREATE NONCLUSTERED INDEX NUK_UGROUP_UPID ON user_group(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_UGROUPMEM_APPID ON user_group_mem_otherdetail(dappraiser)
GO

CREATE NONCLUSTERED INDEX NUK_UJOBPROF_USERID ON user_job_profile(user_id)
GO

CREATE NONCLUSTERED INDEX NUK_UJOBPROF_ASSIBY ON user_job_profile(assigned_by)
GO

CREATE NONCLUSTERED INDEX NUK_UHISACT_PID ON user_merge_history(actor_currentpid)
GO

CREATE NONCLUSTERED INDEX NUK_UHISSOU_METAID ON user_merge_history(source_user_meta_id)
GO

CREATE NONCLUSTERED INDEX NUK_USERHIS_CURTPID ON user_merge_history(target_currentpid)
GO

CREATE NONCLUSTERED INDEX NUK_UOPTPAY_UID ON user_opt_pay_items(userid)
GO

CREATE NONCLUSTERED INDEX NUK_UITM_TRANSID ON user_opt_pay_items(transcriptid)
GO

CREATE NONCLUSTERED INDEX NUK_UPROF_UID ON user_org_job_profile_history(user_id)
GO

CREATE NONCLUSTERED INDEX NUK_UPROF_MID ON user_profile_education(user_meta_id)
GO

CREATE NONCLUSTERED INDEX NUK_UPROFSK_UID ON user_profile_lang_skills(user_meta_id)
GO

CREATE NONCLUSTERED INDEX NUK_UPROFH_MID ON user_profile_work_history(user_meta_id)
GO

CREATE NONCLUSTERED INDEX NUK_UUSE_METAID ON user_terms_of_use(user_meta_id)
GO

CREATE NONCLUSTERED INDEX NUK_UCATMAP_USERID ON usercatalogs_map(userid)
GO

CREATE NONCLUSTERED INDEX NUK_UASSI_DAPPR ON users_assignment(dappraiser)
GO

CREATE NONCLUSTERED INDEX NUK_VCLAU_LUPID ON vc_launcher_generic(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_VCLAUGTT_LUP ON vc_launcher_gtt(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_VCLAUORG_UID ON vc_launcher_gtt_organizer(user_id)
GO

CREATE NONCLUSTERED INDEX NUK_VCLAUTR_UID ON vc_launcher_gtt_training(user_id)
GO

CREATE NONCLUSTERED INDEX NUK_VCLAUSE_UPUID ON vc_launcher_session(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_VCLAU_LUPDID ON vc_launcher_webex(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_VCLAUNW_UID ON vc_user_attribute(userid)
GO

CREATE NONCLUSTERED INDEX NUK_WIDTEM_UID ON widget_page_template(creator_user_id)
GO

CREATE NONCLUSTERED INDEX NUK_WIKI_UID ON wiki_interaction_log(initiator_userid)
GO

CREATE NONCLUSTERED INDEX NUK_WITH_LUPDID ON withdraw_ded_fixed_amount(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_WITHLST_UPDID ON withdraw_ded_opt_pay_items(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_WITHDED_LUPDID ON withdraw_deduction(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_WITHREA_UID ON withdraw_reason(user_id)
GO

CREATE NONCLUSTERED INDEX NUK_WITHREA_TRID ON withdraw_reason(transcript_id)
GO

CREATE NONCLUSTERED INDEX NUK_WITHPOLY_AID ON withdrawal_enrollment_policy(approverid)
GO

CREATE NONCLUSTERED INDEX NUK_WITSTU_TRID ON withdrawnStudents(transcriptid)
GO

CREATE NONCLUSTERED INDEX NUK_CUSE_LUPDID ON certusers_selfaward(last_updater_uid)
GO

CREATE NONCLUSTERED INDEX NUK_TEMCRI_TEMID ON filter_templates_criteria(filter_template_id)
GO

CREATE NONCLUSTERED INDEX NUK_OAUTH_CREVER ON oauth_token_credentials(verifier)
GO

CREATE NONCLUSTERED INDEX NUK_INDIN_INID ON indicator_instance_parameters(indicator_instance_id)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20180306-kk-1', 'Krupa.Kamat', 'nschema/140.changeLog.xml', GETDATE(), 764, '8:2ce62f6a604f75485336aabaa90ab751', 'createIndex indexName=NUK_ACCAUDIT_USERID, tableName=accessAuditTrail; createIndex indexName=NUK_ACC_CREATOR, tableName=accounts; createIndex indexName=NUK_ACNT_LASTUPDATID, tableName=accounts; createIndex indexName=NUK_ADIT_ATMT_GRANTID, tableNam...', 'GDPR Story', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/140.changeLog.xml::20180314-wp-1::william.puk
-- [PD-9027] Handling of Background Task Queues in Multi-Node Environment
ALTER TABLE background_task_log ADD internal_node_id nvarchar(36)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'background_task_log'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.background_task_log'; DECLARE @ColumnName SYSNAME set @ColumnName = N'internal_node_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'The internal node ID. The value is in a UUID format.';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20180314-wp-1', 'william.puk', 'nschema/140.changeLog.xml', GETDATE(), 765, '8:cacd2300a274fdd2a88e636073edbebf', 'addColumn tableName=background_task_log', '[PD-9027] Handling of Background Task Queues in Multi-Node Environment', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/140.changeLog.xml::20180322-wp-1::william.puk
-- PD-9297 Background tasks to support Leader Election
ALTER TABLE background_task_log ADD executed_by_node nvarchar(36)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'background_task_log'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.background_task_log'; DECLARE @ColumnName SYSNAME set @ColumnName = N'executed_by_node'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'The internal ID of node which executed this task. The value is in a UUID format.';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20180322-wp-1', 'william.puk', 'nschema/140.changeLog.xml', GETDATE(), 766, '8:6bc1fecf6dc588247f4a33967e2feb55', 'addColumn tableName=background_task_log', 'PD-9297 Background tasks to support Leader Election', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/141.changeLog.xml::27Apr2018-gl-1::garbo.lim
UPDATE ekpversion SET dblevel = 141, splevel = 0
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('27Apr2018-gl-1', 'garbo.lim', 'nschema/141.changeLog.xml', GETDATE(), 767, '8:6c8d4ed586d94cf366c217b6a0ca3163', 'update tableName=ekpversion', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/141.changeLog.xml::20180516-tc-1::tommy.chu
-- [NSD-3] As a user with unrestricted role access to the Enrollment Policy Editor, I want to save a template as the New Sessions Available Notification for an enrollment policy
ALTER TABLE enrollment_policy ADD new_ses_avail_email_profile_id nvarchar(15)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'enrollment_policy'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.enrollment_policy'; DECLARE @ColumnName SYSNAME set @ColumnName = N'new_ses_avail_email_profile_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'New-Session-Available Email Profile Id';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20180516-tc-1', 'tommy.chu', 'nschema/141.changeLog.xml', GETDATE(), 768, '8:e94538a2a351274b65fe3eff1fb9122d', 'addColumn tableName=enrollment_policy', '[NSD-3] As a user with unrestricted role access to the Enrollment Policy Editor, I want to save a template as the New Sessions Available Notification for an enrollment policy', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/141.changeLog.xml::20180528-if-1::ivan.fung
-- [NSD-27] Add account table for Vitero Virtual Classroom
CREATE TABLE vc_vitero_account (account_id nvarchar(85) NOT NULL, display_name nvarchar(1020) NOT NULL, host_name nvarchar(1020) NOT NULL, customer_id int NOT NULL, admin_username nvarchar(1020) NOT NULL, admin_password nvarchar(1020) NOT NULL, CONSTRAINT PK_VC_VITERO_ACC PRIMARY KEY (account_id))
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_account'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_account'; DECLARE @ColumnName SYSNAME set @ColumnName = N'account_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Primary key';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_account'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_account'; DECLARE @ColumnName SYSNAME set @ColumnName = N'display_name'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Display Name';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_account'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_account'; DECLARE @ColumnName SYSNAME set @ColumnName = N'host_name'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Vitero Host Name';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_account'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_account'; DECLARE @ColumnName SYSNAME set @ColumnName = N'customer_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Vitero Customer ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_account'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_account'; DECLARE @ColumnName SYSNAME set @ColumnName = N'admin_username'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Vitero Administrator Username';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_account'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_account'; DECLARE @ColumnName SYSNAME set @ColumnName = N'admin_password'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Vitero Administrator Password';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20180528-if-1', 'ivan.fung', 'nschema/141.changeLog.xml', GETDATE(), 769, '8:28a05c8f4a8a7f0ca3041d235b70c305', 'createTable tableName=vc_vitero_account', '[NSD-27] Add account table for Vitero Virtual Classroom', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/141.changeLog.xml::20180528-ny-1::nelson.yip
-- [NSD-29]Add Vitero launcher configuration table
CREATE TABLE vc_launcher_vitero (course_id nvarchar(85) NOT NULL, account_id nvarchar(85) NOT NULL, last_updater_uid nvarchar(85), last_updated datetime, updater_legal_name nvarchar(1000), update_meaning_text nvarchar (max), CONSTRAINT PK_VC_LAUNCHER_VITERO PRIMARY KEY (course_id))
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_launcher_vitero'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_launcher_vitero'; DECLARE @ColumnName SYSNAME set @ColumnName = N'course_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Primary key, Learning ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_launcher_vitero'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_launcher_vitero'; DECLARE @ColumnName SYSNAME set @ColumnName = N'account_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Vitero Account ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_launcher_vitero'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_launcher_vitero'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_updater_uid'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'UID of change maker';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_launcher_vitero'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_launcher_vitero'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_updated'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'System datetime of the change';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_launcher_vitero'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_launcher_vitero'; DECLARE @ColumnName SYSNAME set @ColumnName = N'updater_legal_name'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Legal name of change maker';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_launcher_vitero'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_launcher_vitero'; DECLARE @ColumnName SYSNAME set @ColumnName = N'update_meaning_text'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Update remark';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

CREATE NONCLUSTERED INDEX NUK_VCLAUVIT_LUPDID ON vc_launcher_vitero(last_updater_uid)
GO

ALTER TABLE vc_launcher_vitero ADD CONSTRAINT FK_VCLAUVIT_ACCOUNTID FOREIGN KEY (account_id) REFERENCES vc_vitero_account (account_id)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20180528-ny-1', 'nelson.yip', 'nschema/141.changeLog.xml', GETDATE(), 770, '8:6acc8b7b2ab8c98f4fc0b5c6f2c5961c', 'createTable tableName=vc_launcher_vitero; createIndex indexName=NUK_VCLAUVIT_LUPDID, tableName=vc_launcher_vitero; addForeignKeyConstraint baseTableName=vc_launcher_vitero, constraintName=FK_VCLAUVIT_ACCOUNTID, referencedTableName=vc_vitero_account', '[NSD-29]Add Vitero launcher configuration table', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/141.changeLog.xml::20180608-tc-1::tommy.chu
-- [NSD-10] send one New Sessions Available Notification per learner per module
CREATE TABLE bg_task_to_be_merged_log (id nvarchar(85) NOT NULL, group_id nvarchar(85) NOT NULL, task_key smallint NOT NULL, request_user_id nvarchar(85), created_datetime datetime NOT NULL, parameters nvarchar (max), CONSTRAINT PK_BG_TASK_TO_BE_MERGED PRIMARY KEY (id))
GO

CREATE NONCLUSTERED INDEX NUK_BGTBM_GID ON bg_task_to_be_merged_log(group_id)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20180608-tc-1', 'tommy.chu', 'nschema/141.changeLog.xml', GETDATE(), 771, '8:f3168c8d36e98cf772e424a54691f593', 'createTable tableName=bg_task_to_be_merged_log; createIndex indexName=NUK_BGTBM_GID, tableName=bg_task_to_be_merged_log', '[NSD-10] send one New Sessions Available Notification per learner per module', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/141.changeLog.xml::20180613-ps-1::paul.strugnell
-- [NSD-32] Add session table for Vitero Virtual Classroom
CREATE TABLE vc_vitero_session (session_id nvarchar(15) NOT NULL, learning_id nvarchar(85) NOT NULL, sync_status char(1) NOT NULL, last_sync datetime, last_sync_uid nvarchar(85), vitero_group_id int, vitero_session_code nvarchar(255), CONSTRAINT PK_VC_VITERO_SESSION PRIMARY KEY (session_id))
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_session'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_session'; DECLARE @ColumnName SYSNAME set @ColumnName = N'session_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Session ID (primary key)';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_session'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_session'; DECLARE @ColumnName SYSNAME set @ColumnName = N'learning_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Learning ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_session'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_session'; DECLARE @ColumnName SYSNAME set @ColumnName = N'sync_status'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Sync Status';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_session'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_session'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_sync'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'System datetime of last sync';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_session'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_session'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_sync_uid'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'UID of last sync invoker';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_session'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_session'; DECLARE @ColumnName SYSNAME set @ColumnName = N'vitero_group_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Vitero Group ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_session'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_session'; DECLARE @ColumnName SYSNAME set @ColumnName = N'vitero_session_code'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Vitero Session Code';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

ALTER TABLE vc_vitero_session ADD CONSTRAINT FK_VC_VITERO_SESSION_LID FOREIGN KEY (learning_id) REFERENCES learningObject (learningid)
GO

ALTER TABLE vc_vitero_session ADD CONSTRAINT FK_VC_VITERO_SESSION_SID FOREIGN KEY (session_id) REFERENCES cschedule (eventid)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20180613-ps-1', 'paul.strugnell', 'nschema/141.changeLog.xml', GETDATE(), 772, '8:54e22264d5b08bcb6521a33614e365f2', 'createTable tableName=vc_vitero_session; addForeignKeyConstraint baseTableName=vc_vitero_session, constraintName=FK_VC_VITERO_SESSION_LID, referencedTableName=learningObject; addForeignKeyConstraint baseTableName=vc_vitero_session, constraintName=...', '[NSD-32] Add session table for Vitero Virtual Classroom', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/141.changeLog.xml::20180613-ps-2::paul.strugnell
-- [NSD-32] Add sync log table for Vitero Virtual Classroom
CREATE TABLE vc_vitero_sync_log (log_id nvarchar(85) NOT NULL, log_time datetime NOT NULL, session_id nvarchar(15) NOT NULL, resource_key nvarchar(255) NOT NULL, params nvarchar (max), CONSTRAINT PK_VC_VITERO_SYNC_LOG PRIMARY KEY (log_id))
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_sync_log'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_sync_log'; DECLARE @ColumnName SYSNAME set @ColumnName = N'log_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Log ID (primary key)';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_sync_log'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_sync_log'; DECLARE @ColumnName SYSNAME set @ColumnName = N'log_time'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'System datetime of this log entry';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_sync_log'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_sync_log'; DECLARE @ColumnName SYSNAME set @ColumnName = N'session_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Session ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_sync_log'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_sync_log'; DECLARE @ColumnName SYSNAME set @ColumnName = N'resource_key'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Resource Key';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_sync_log'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_sync_log'; DECLARE @ColumnName SYSNAME set @ColumnName = N'params'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Params for log message variables (JSON array)';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

CREATE NONCLUSTERED INDEX NUK_VC_VIT_SYNC_LOG_SID ON vc_vitero_sync_log(session_id)
GO

ALTER TABLE vc_vitero_sync_log ADD CONSTRAINT FK_VC_VIT_SYNC_LOG_SID FOREIGN KEY (session_id) REFERENCES cschedule (eventid)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20180613-ps-2', 'paul.strugnell', 'nschema/141.changeLog.xml', GETDATE(), 773, '8:dd9d9c4ae9aeab2a74bd4831a64b285a', 'createTable tableName=vc_vitero_sync_log; createIndex indexName=NUK_VC_VIT_SYNC_LOG_SID, tableName=vc_vitero_sync_log; addForeignKeyConstraint baseTableName=vc_vitero_sync_log, constraintName=FK_VC_VIT_SYNC_LOG_SID, referencedTableName=cschedule', '[NSD-32] Add sync log table for Vitero Virtual Classroom', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/141.changeLog.xml::20180621-if-1::ivan.fung
-- [NSD-35] Table for Vitero User ID to user meta ID mapping
CREATE TABLE vc_vitero_user (user_meta_id nvarchar(85) NOT NULL, account_id nvarchar(85) NOT NULL, vitero_user_id int NOT NULL, last_sync datetime NOT NULL)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_user'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_user'; DECLARE @ColumnName SYSNAME set @ColumnName = N'user_meta_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Related User Meta ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_user'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_user'; DECLARE @ColumnName SYSNAME set @ColumnName = N'account_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Account ID of the Virtual Classroom account';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_user'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_user'; DECLARE @ColumnName SYSNAME set @ColumnName = N'vitero_user_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Vitero User ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_user'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_user'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_sync'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Date/time of last sync start time';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

ALTER TABLE vc_vitero_user ADD CONSTRAINT PK_VC_VIT_USER PRIMARY KEY (user_meta_id, account_id)
GO

ALTER TABLE vc_vitero_user ADD CONSTRAINT FK_VC_VIT_USER_META FOREIGN KEY (user_meta_id) REFERENCES users_meta (user_meta_id)
GO

ALTER TABLE vc_vitero_user ADD CONSTRAINT FK_VC_VIT_ACT_ID FOREIGN KEY (account_id) REFERENCES vc_vitero_account (account_id)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20180621-if-1', 'ivan.fung', 'nschema/141.changeLog.xml', GETDATE(), 774, '8:3d94f984930102b1cebe803192d50636', 'createTable tableName=vc_vitero_user; addPrimaryKey constraintName=PK_VC_VIT_USER, tableName=vc_vitero_user; addForeignKeyConstraint baseTableName=vc_vitero_user, constraintName=FK_VC_VIT_USER_META, referencedTableName=users_meta; addForeignKeyCon...', '[NSD-35] Table for Vitero User ID to user meta ID mapping', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/141.changeLog.xml::20180620-ny-1::nelson.yip
-- [NSD-34] Add Vitero Booking Table
CREATE TABLE vc_vitero_booking (event_id nvarchar(15) NOT NULL, session_id nvarchar(15) NOT NULL, vitero_booking_id nvarchar(255), CONSTRAINT PK_VC_VITERO_BOOKING PRIMARY KEY (event_id))
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_booking'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_booking'; DECLARE @ColumnName SYSNAME set @ColumnName = N'event_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'NTS Schedule Item Event ID (primary key)';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_booking'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_booking'; DECLARE @ColumnName SYSNAME set @ColumnName = N'session_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Session ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_vitero_booking'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_vitero_booking'; DECLARE @ColumnName SYSNAME set @ColumnName = N'vitero_booking_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Vitero Booking ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

CREATE NONCLUSTERED INDEX NUK_VC_VIT_BK_SESSION_ID ON vc_vitero_booking(session_id)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20180620-ny-1', 'nelson.yip', 'nschema/141.changeLog.xml', GETDATE(), 775, '8:4f8e407213f223b55b1fb6fecc469682', 'createTable tableName=vc_vitero_booking; createIndex indexName=NUK_VC_VIT_BK_SESSION_ID, tableName=vc_vitero_booking', '[NSD-34] Add Vitero Booking Table', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/141.changeLog.xml::20180716-aa-1::adams.au
-- NSD-821 Terms of Use Acceptance Withdrawal
ALTER TABLE user_terms_of_use ADD withdraw_date datetime
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_terms_of_use'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_terms_of_use'; DECLARE @ColumnName SYSNAME set @ColumnName = N'withdraw_date'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'withdraw date of the terms of use';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

ALTER TABLE user_terms_of_use ALTER COLUMN accepted_date datetime NULL
GO

CREATE TABLE user_terms_of_use_history (history_id nvarchar(85) NOT NULL, user_meta_id nvarchar(85) NOT NULL, terms_id nvarchar(85) NOT NULL, created_date datetime NOT NULL, accepted_date datetime, withdraw_date datetime, CONSTRAINT PK_USER_TERMS_OF_USE_HISTORY PRIMARY KEY (history_id))
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_terms_of_use_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_terms_of_use_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'history_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'surrogate id of terms of use history';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_terms_of_use_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_terms_of_use_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'user_meta_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'user meta id of the terms of use history';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_terms_of_use_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_terms_of_use_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'terms_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'terms id of the terms of use history';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_terms_of_use_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_terms_of_use_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'created_date'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'created date of the terms of use history';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_terms_of_use_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_terms_of_use_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'accepted_date'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'accepted date of terms of use history';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_terms_of_use_history'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_terms_of_use_history'; DECLARE @ColumnName SYSNAME set @ColumnName = N'withdraw_date'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'withdraw date of the terms of use history';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

ALTER TABLE user_terms_of_use_history ADD CONSTRAINT FK_TOU_HIST_USER_META_ID FOREIGN KEY (user_meta_id) REFERENCES users_meta (user_meta_id)
GO

ALTER TABLE user_terms_of_use_history ADD CONSTRAINT FK_TOU_HIST_TERMS_ID FOREIGN KEY (terms_id) REFERENCES terms_of_use (id)
GO

CREATE NONCLUSTERED INDEX NUK_USERMETA_TERMS ON user_terms_of_use_history(user_meta_id, terms_id)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20180716-aa-1', 'adams.au', 'nschema/141.changeLog.xml', GETDATE(), 776, '8:af57807f633cd574d91ab6333f7ea41b', 'addColumn tableName=user_terms_of_use; dropNotNullConstraint columnName=accepted_date, tableName=user_terms_of_use; createTable tableName=user_terms_of_use_history; addForeignKeyConstraint baseTableName=user_terms_of_use_history, constraintName=FK...', 'NSD-821 Terms of Use Acceptance Withdrawal', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/141.changeLog.xml::20180802-ca-1::chris.au
-- [NSD-1008] S2 - [SEW] Demo Units Upgrade 12.2 -> 13.2
ALTER TABLE training_resource_reservation ALTER COLUMN title nvarchar(450)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20180802-ca-1', 'chris.au', 'nschema/141.changeLog.xml', GETDATE(), 777, '8:583aae62bf1f682b149ea6ab96c390d4', 'modifyDataType columnName=title, tableName=training_resource_reservation', '[NSD-1008] S2 - [SEW] Demo Units Upgrade 12.2 -> 13.2', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/141.changeLog.xml::20180726-ly-1::leo.yiu
-- NSD-756 - Reserve Seats, Count waitlist as well when the count method is P
INSERT INTO code_enroll_cnt_method (method, studentstatus, consider_reserve_only) VALUES ('P', 1, 'Y')
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20180726-ly-1', 'leo.yiu', 'nschema/141.changeLog.xml', GETDATE(), 778, '8:60a65e1cd37264ca9b495ddddebf46c1', 'insert tableName=code_enroll_cnt_method', 'NSD-756 - Reserve Seats, Count waitlist as well when the count method is P', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/141.changeLog.xml::20180816-if-1::ivan.fung
-- [NSD-1012]Deduct One Off Token Payments
ALTER TABLE token_transaction ADD learning_id nvarchar(85)
GO

ALTER TABLE token_transaction ADD session_id nvarchar(15)
GO

ALTER TABLE token_transaction ADD organization_id nvarchar(15)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'token_transaction'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.token_transaction'; DECLARE @ColumnName SYSNAME set @ColumnName = N'learning_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'learning module id';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'token_transaction'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.token_transaction'; DECLARE @ColumnName SYSNAME set @ColumnName = N'session_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'session id';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'token_transaction'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.token_transaction'; DECLARE @ColumnName SYSNAME set @ColumnName = N'organization_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'organization id';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

CREATE NONCLUSTERED INDEX NUK_SESSION_ID ON token_transaction(session_id)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20180816-if-1', 'ivan.fung', 'nschema/141.changeLog.xml', GETDATE(), 779, '8:9bf3b24ce6533aea64fd96a28882e215', 'addColumn tableName=token_transaction; createIndex indexName=NUK_SESSION_ID, tableName=token_transaction', '[NSD-1012]Deduct One Off Token Payments', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/141.changeLog.xml::20180824-if-1::ivan.fung
-- [NSD-1013]Refund One Off Token Payments
ALTER TABLE token_transaction ADD refund_by_id nvarchar(15)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'token_transaction'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.token_transaction'; DECLARE @ColumnName SYSNAME set @ColumnName = N'refund_by_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'The transaction id which refunded this record';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

ALTER TABLE token_transaction ADD CONSTRAINT FK_TK_REFUND_BY_ID FOREIGN KEY (refund_by_id) REFERENCES token_transaction (token_transaction_id)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20180824-if-1', 'ivan.fung', 'nschema/141.changeLog.xml', GETDATE(), 780, '8:1cb794e3967940a8c3080cf7b9ab6e23', 'addColumn tableName=token_transaction; addForeignKeyConstraint baseTableName=token_transaction, constraintName=FK_TK_REFUND_BY_ID, referencedTableName=token_transaction', '[NSD-1013]Refund One Off Token Payments', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/150.changeLog.xml::24Oct2018-gl-1::garbo.lim
UPDATE ekpversion SET dblevel = 150, splevel = 0
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('24Oct2018-gl-1', 'garbo.lim', 'nschema/150.changeLog.xml', GETDATE(), 781, '8:fdd9ee201e1fc6a3447c3457bbb571ef', 'update tableName=ekpversion', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/150.changeLog.xml::20181210-jh-1::jiaju.he
-- [NSD-1285] Access to Reports from Other Users
ALTER TABLE batchreport ADD schedule_report_id nvarchar(15)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'batchreport'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.batchreport'; DECLARE @ColumnName SYSNAME set @ColumnName = N'schedule_report_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Schedule Report ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

UPDATE batchreport SET schedule_report_id = '*UNKNOWN*' WHERE schedule_report_id IS NULL
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20181210-jh-1', 'jiaju.he', 'nschema/150.changeLog.xml', GETDATE(), 782, '8:0774c1f722cb58b548f07287fd26253e', 'addColumn tableName=batchreport; sql', '[NSD-1285] Access to Reports from Other Users', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/150.changeLog.xml::20190328-sc-1::starry.chan
-- NPD-402 LMS to iPaaS User Account Synchronization
ALTER TABLE users_meta ADD ipaas_id nvarchar(85)
GO

ALTER TABLE users_meta ADD hris_external_id nvarchar(85)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'users_meta'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.users_meta'; DECLARE @ColumnName SYSNAME set @ColumnName = N'ipaas_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'iPaaS ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'users_meta'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.users_meta'; DECLARE @ColumnName SYSNAME set @ColumnName = N'hris_external_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'HRIS External ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20190328-sc-1', 'starry.chan', 'nschema/150.changeLog.xml', GETDATE(), 783, '8:e1c5ec68fa39872ef942e960c5ec0d2e', 'addColumn tableName=users_meta', 'NPD-402 LMS to iPaaS User Account Synchronization', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/151.changeLog.xml::20190531-ps-1::paul.strugnell
UPDATE ekpversion SET dblevel = 151, splevel = 0
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20190531-ps-1', 'paul.strugnell', 'nschema/151.changeLog.xml', GETDATE(), 784, '8:84e22db467d3f771b27ca2d3d091eeaa', 'update tableName=ekpversion', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/152.changeLog.xml::20200122-ps-1::paul.strugnell
UPDATE ekpversion SET dblevel = 152, splevel = 0
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20200122-ps-1', 'paul.strugnell', 'nschema/152.changeLog.xml', GETDATE(), 785, '8:5e4d2a3214265e011191e836739f96de', 'update tableName=ekpversion', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/152.changeLog.xml::20200218-js-1::michael.gorohov
-- Change the column size of testid to 100 symbols
ALTER TABLE exam_workflow_step DROP CONSTRAINT FK_exam_workflow_step02
GO

ALTER TABLE mastertest DROP CONSTRAINT PK_MASTERTEST
GO

ALTER TABLE exam_workflow_step ALTER COLUMN testid NVARCHAR(100) NOT NULL
GO

ALTER TABLE mastertest ALTER COLUMN testid NVARCHAR(100) NOT NULL
GO

ALTER TABLE mastertest ALTER COLUMN parenttestid NVARCHAR(100)
GO

ALTER TABLE mastertest ALTER COLUMN resitParentTestId NVARCHAR(100)
GO

ALTER TABLE mastertest ADD CONSTRAINT PK_MASTERTEST PRIMARY KEY (testid)
GO

ALTER TABLE exam_workflow_step ADD CONSTRAINT FK_exam_workflow_step02 FOREIGN KEY (testid) REFERENCES mastertest (testid)
GO

ALTER TABLE mastertest_print DROP CONSTRAINT PK_MASTERTEST_PRINT
GO

ALTER TABLE mastertest_print ALTER COLUMN testid NVARCHAR(100) NOT NULL
GO

ALTER TABLE mastertest_print ADD CONSTRAINT PK_MASTERTEST_PRINT PRIMARY KEY (testid)
GO

ALTER TABLE randsection DROP CONSTRAINT PK_RANDSECTION
GO

ALTER TABLE randsection ALTER COLUMN testid NVARCHAR(100) NOT NULL
GO

ALTER TABLE randsection ADD CONSTRAINT PK_RANDSECTION PRIMARY KEY (testid, sectionnum, ordernum)
GO

ALTER TABLE test_pools DROP CONSTRAINT PK_TPOOLS
GO

ALTER TABLE test_pools ALTER COLUMN testid NVARCHAR(100) NOT NULL
GO

ALTER TABLE test_pools ADD CONSTRAINT PK_TPOOLS PRIMARY KEY (testid, sequence)
GO

ALTER TABLE coursetest DROP CONSTRAINT PK_COURSETEST
GO

ALTER TABLE coursetest ALTER COLUMN testid NVARCHAR(100) NOT NULL
GO

ALTER TABLE coursetest ADD CONSTRAINT PK_COURSETEST PRIMARY KEY (courseid, testid)
GO

ALTER TABLE ip_filter_table DROP CONSTRAINT PK_IP_FILTER_TABLE
GO

ALTER TABLE ip_filter_table ALTER COLUMN testid NVARCHAR(100) NOT NULL
GO

ALTER TABLE ip_filter_table ADD CONSTRAINT PK_IP_FILTER_TABLE PRIMARY KEY (testid, qindex)
GO

ALTER TABLE mastersection ALTER COLUMN testid NVARCHAR(100) NOT NULL
GO

ALTER TABLE masterquestion ALTER COLUMN testid NVARCHAR(100) NOT NULL
GO

ALTER TABLE article ALTER COLUMN testid NVARCHAR(100)
GO

ALTER TABLE certifications ALTER COLUMN testid NVARCHAR(100)
GO

ALTER TABLE evaluation ALTER COLUMN testid NVARCHAR(100) NOT NULL
GO

ALTER TABLE skills ALTER COLUMN testid NVARCHAR(100) NOT NULL
GO

ALTER TABLE survey ALTER COLUMN testid NVARCHAR(100) NOT NULL
GO

ALTER TABLE testinstance ALTER COLUMN testid NVARCHAR(100) NOT NULL
GO

ALTER TABLE ContentObject ALTER COLUMN testID NVARCHAR(100)
GO

ALTER TABLE curriculum ALTER COLUMN certtestid NVARCHAR(100)
GO

ALTER TABLE enrollment_policy_ext_details ALTER COLUMN value_testid NVARCHAR(100)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20200218-js-1', 'michael.gorohov', 'nschema/152.changeLog.xml', GETDATE(), 786, '8:9ec5ca36ea465988573f55903a9995ca', 'sql; sql; sql', 'Change the column size of testid to 100 symbols', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/152.changeLog.xml::20200429-yf-1::Yueqin Feng
-- PL-198: add remarks to the deprecated table/columns related with chat feature
ALTER TABLE knowledgecenteroptions ALTER COLUMN chatroom_area char(1) NULL
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'chatrooms'; DECLARE @FullTableName SYSNAME; SET @FullTableName = @DynamicSchemaName + N'.chatrooms';DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'deprecated table';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.name = N'MS_Description' AND ep.minor_id=0); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'learningObject'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.learningObject'; DECLARE @ColumnName SYSNAME set @ColumnName = N'assignedChatRoom'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'deprecated column';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'knowledgecenteroptions'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.knowledgecenteroptions'; DECLARE @ColumnName SYSNAME set @ColumnName = N'chatroom_area'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'deprecated column';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20200429-yf-1', 'Yueqin Feng', 'nschema/152.changeLog.xml', GETDATE(), 787, '8:f4f606b4251b46b085085357ecfe0d3f', 'dropNotNullConstraint columnName=chatroom_area, tableName=knowledgecenteroptions; setTableRemarks tableName=chatrooms; setColumnRemarks columnName=assignedChatRoom, tableName=learningObject; setColumnRemarks columnName=chatroom_area, tableName=kno...', 'PL-198: add remarks to the deprecated table/columns related with chat feature', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/152.changeLog.xml::20200429-yf-3::Yueqin Feng
-- Remove assignedChatRoom from the view
DROP VIEW learningObject_vw
GO

CREATE VIEW learningObject_vw AS select lo.learningid,lo.learningType,lo.mediaid,lo.subject,lo.title,lo.description1,lo.hyperlink,lo.assignedForum,lo.editcontrol,lo.showInCatalog,lo.allowPeerReview,lo.datecreated,lo.autoDelete,lo.deleteDate,lo.picture,lo.evaluation,lo.evalRequired,lo.duration,lo.policyid,lo.org_policy_override,lo.prereqcontrol,lo.testRequired,lo.startAvailabilityDate,lo.endAvailabilityDate,lo.vendorname,lo.allowReopen,lo.testEnablesCompletion,lo.enforcePrePostTestOrder,lo.completionTimeLimit,lo.allowReEnroll,lo.historyExpireWindow,lo.display_course_interest,lo.wikiURL,lo.supervisorAssessment,lo.allowDappraiserAssess,lo.sticky,lo.creator_uid,lo.last_updated,lo.last_updater_uid,lo.mekp_target,lo.update_meaning,lo.wiki_key,lo.wiki_display,lo.archived,lo.updater_legal_name,lo.update_meaning_text,lo.auto_archive_date,lo.show_expiration_date,lo.show_begin_date,lo.subject_category_id,lo.require_esignature,lo.support_contact,lo.domain_id,lo.allow_auto_recommend,lo.allowSupervisorAssess,lo.esig_course_withdraw,lo.esig_course_modify,lo.esig_course_launch,lo.esig_course_import,lo.esig_course_finish,lo.esig_exam_launch,lo.esig_wizard_modify_trans,lo.esig_reviewer_modify_trans,lo.esig_editor_modify_trans,lo.esig_modify_attendance,lo.esig_course_withdraw_meaning,lo.esig_course_modify_meaning,lo.esig_course_launch_meaning,lo.esig_course_import_meaning,lo.esig_course_finish_meaning,lo.esig_exam_launch_meaning,lo.esig_wzrd_modify_trans_meaning,lo.esig_rvwr_modify_trans_meaning,lo.esig_edtr_modify_trans_meaning,lo.esig_modify_attendance_meaning,lo.esig_equi_rule,lo.esig_equi_rule_meaning,lang.ilangid as language, lang.locale, lang.bundle_id,
            case when lang.ilangid is null then lang.locale else cast(lang.ilangid as char(85)) end language_tag, lo.display_learning_id
            from learningObject lo
            left join language_bundle lang on lang.object_id = lo.learningid and lang.object_type = 'LO' and is_primary = 'Y'
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20200429-yf-3', 'Yueqin Feng', 'nschema/152.changeLog.xml', GETDATE(), 788, '8:9016488ab1c54ff9a6b3f6447b1d35b2', 'dropView viewName=learningObject_vw; createView viewName=learningObject_vw', 'Remove assignedChatRoom from the view', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/152.changeLog.xml::20200601-yf-1::Yueqin Feng
-- Create a configuration option that will enable the new UI pages
DROP VIEW userprefs
GO

ALTER TABLE userprefs_assignment ADD enable_newui char(1) CONSTRAINT DF_userprefs_assignment_enable_newui DEFAULT 'N' NOT NULL
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'userprefs_assignment'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.userprefs_assignment'; DECLARE @ColumnName SYSNAME set @ColumnName = N'enable_newui'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Configuration option to display new UI pages';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

CREATE VIEW userprefs AS select userprefs_assignment.userid,
            userprefs_assignment.contentServer,
            userprefs_assignment.ui,
            users_meta.languagepref,
            userprefs_assignment.autoMailList,
            userprefs_assignment.autoRegMsg,
            users_meta.useExternalMail,
            userprefs_assignment.initialURL,
            userprefs_assignment.resultsPerPage,
            userprefs_assignment.catalogid,
            userprefs_assignment.userPref1,
            userprefs_assignment.userPref2,
            userprefs_assignment.time_zone,
            users_meta.email_forward_type,
            users_meta.forward_to_email,
            userprefs_assignment.welcome_email_senddate,
            users_meta.block_notification,
            userprefs_assignment.enable_newui
            from userprefs_assignment
            JOIN users_assignment on userprefs_assignment.userid = users_assignment.userid
            JOIN users_meta on users_assignment.user_meta_id = users_meta.user_meta_id
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20200601-yf-1', 'Yueqin Feng', 'nschema/152.changeLog.xml', GETDATE(), 789, '8:95253942ff22d701bdd90f67db345d19', 'dropView viewName=userprefs; addColumn tableName=userprefs_assignment; createView viewName=userprefs', 'Create a configuration option that will enable the new UI pages', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/153.changeLog.xml::20200811-jh-1::jiaju.he
UPDATE ekpversion SET dblevel = 153, splevel = 0
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20200811-jh-1', 'jiaju.he', 'nschema/153.changeLog.xml', GETDATE(), 790, '8:92006c3698a2b95561fa66283807ba5e', 'update tableName=ekpversion', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/153.changeLog.xml::20201103-jh-1::jiaju.he
-- PL-1168: Group Enroll/Withdraw High Execution Time in 15.2
CREATE NONCLUSTERED INDEX NUK_REG_EVENT_STUDENTSTATUS ON registration(eventid, studentstatus)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20201103-jh-1', 'jiaju.he', 'nschema/153.changeLog.xml', GETDATE(), 791, '8:b66290e2499572f4443c6f0b35aaebbf', 'createIndex indexName=NUK_REG_EVENT_STUDENTSTATUS, tableName=registration', 'PL-1168: Group Enroll/Withdraw High Execution Time in 15.2', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/153.changeLog.xml::20201102-yf-01::yueqin.feng
-- PL-600: Make new home page default home page
INSERT INTO code_initialURL (pageid, description, pageURL) VALUES (20, 'label.firstscreen.widget_page', '/servlet/ekp?TX=WIDGETCONTAINERPAGE')
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20201102-yf-01', 'yueqin.feng', 'nschema/153.changeLog.xml', GETDATE(), 792, '8:fc46dd3653618f1fc02cd47cacc362f5', 'insert tableName=code_initialURL', 'PL-600: Make new home page default home page', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2104.changeLog.xml::20201125-en-1::eddie.ng
UPDATE ekpversion SET dblevel = 2104, splevel = 0
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20201125-en-1', 'eddie.ng', 'nschema/2104.changeLog.xml', GETDATE(), 793, '8:90b9fbba75343a39be032b9c03472a77', 'update tableName=ekpversion', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2104.changeLog.xml::20210218-rb-1::ryan.buchanan
-- NSD-6225
UPDATE logical_domain_config SET config_value = 'MEDIUM' WHERE config_key LIKE 'security.ScanDataInput' AND config_value LIKE 'STANDARD'
GO

UPDATE logical_domain_config SET config_value = 'true' WHERE config_key LIKE 'security.HtmlSanitizerEnabled'
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20210218-rb-1', 'ryan.buchanan', 'nschema/2104.changeLog.xml', GETDATE(), 794, '8:9245d44ac15ef87cd646a43d93be526c', 'update tableName=logical_domain_config; update tableName=logical_domain_config', 'NSD-6225', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2104.changeLog.xml::20210220-sc-1::shu.cui
-- This table stores Microsoft Teams account information
CREATE TABLE vc_ms_teams_account (account_id nvarchar(85) NOT NULL, display_name nvarchar(1000) NOT NULL, client_id nvarchar(255) NOT NULL, tenant_id nvarchar(255) NOT NULL, client_secret nvarchar(255) NOT NULL, CONSTRAINT PK_VC_MS_TEAMS_ACCOUNT PRIMARY KEY (account_id))
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_account'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_account'; DECLARE @ColumnName SYSNAME set @ColumnName = N'account_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Primary key';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_account'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_account'; DECLARE @ColumnName SYSNAME set @ColumnName = N'display_name'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Display Name';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_account'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_account'; DECLARE @ColumnName SYSNAME set @ColumnName = N'client_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Client ID from Microsoft';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_account'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_account'; DECLARE @ColumnName SYSNAME set @ColumnName = N'tenant_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Tenant ID from Microsoft';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_account'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_account'; DECLARE @ColumnName SYSNAME set @ColumnName = N'client_secret'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Client secret value from Microsoft';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20210220-sc-1', 'shu.cui', 'nschema/2104.changeLog.xml', GETDATE(), 795, '8:aa9653aa553946f93212f8fcd13526c5', 'createTable tableName=vc_ms_teams_account', 'This table stores Microsoft Teams account information', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2104.changeLog.xml::20210302-ps-1::paul.strugnell
-- [PL-1435] Add MS Teams launcher configuration table
CREATE TABLE vc_launcher_ms_teams (course_id nvarchar(85) NOT NULL, account_id nvarchar(85) NOT NULL, last_updater_uid nvarchar(85), last_updated datetime, updater_legal_name nvarchar(1000), update_meaning_text nvarchar (max), CONSTRAINT PK_VC_LAUNCHER_MS_TEAMS PRIMARY KEY (course_id))
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_launcher_ms_teams'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_launcher_ms_teams'; DECLARE @ColumnName SYSNAME set @ColumnName = N'course_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Primary key, Learning ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_launcher_ms_teams'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_launcher_ms_teams'; DECLARE @ColumnName SYSNAME set @ColumnName = N'account_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'MS Teams virtual classroom account ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_launcher_ms_teams'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_launcher_ms_teams'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_updater_uid'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'UID of change maker';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_launcher_ms_teams'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_launcher_ms_teams'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_updated'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'System datetime of the change';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_launcher_ms_teams'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_launcher_ms_teams'; DECLARE @ColumnName SYSNAME set @ColumnName = N'updater_legal_name'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Legal name of change maker';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_launcher_ms_teams'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_launcher_ms_teams'; DECLARE @ColumnName SYSNAME set @ColumnName = N'update_meaning_text'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Update remark';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

CREATE NONCLUSTERED INDEX NUK_VCLAUMST_LUPDID ON vc_launcher_ms_teams(last_updater_uid)
GO

ALTER TABLE vc_launcher_ms_teams ADD CONSTRAINT FK_VCLAUMST_ACCOUNTID FOREIGN KEY (account_id) REFERENCES vc_ms_teams_account (account_id)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20210302-ps-1', 'paul.strugnell', 'nschema/2104.changeLog.xml', GETDATE(), 796, '8:451584ead7946378c7bebf31a78f7e55', 'createTable tableName=vc_launcher_ms_teams; createIndex indexName=NUK_VCLAUMST_LUPDID, tableName=vc_launcher_ms_teams; addForeignKeyConstraint baseTableName=vc_launcher_ms_teams, constraintName=FK_VCLAUMST_ACCOUNTID, referencedTableName=vc_ms_team...', '[PL-1435] Add MS Teams launcher configuration table', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2104.changeLog.xml::20210308-jj-1::jim.johnson
-- NSD-3379 - Adding skin extensions
UPDATE logical_domain_config SET config_value=cast(config_value as nvarchar(max))+'.aif,.aiff,.au,.avi,.bak,.bmp,.crs,.css,.cst,.csv,.des,.doc,.docx,.eot,.gif,.jpeg,.jpg,.m4a,.mov,.mp3,.mp4,.mpeg,.mpg,.ods,.odt,.otf,.pdf,.png,.pps,.ppt,.pptx,.properties,.rtf,.svg,.ttf,.txt,.wav,.woff,.woff2,.xls,.xlsx,.xml,.zip,.map,.js' WHERE config_key='security.allowedFiles'
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20210308-jj-1', 'jim.johnson', 'nschema/2104.changeLog.xml', GETDATE(), 797, '8:cdb2d6bba1f81b1051fc06d0efd7efd4', 'sql; sql; sql', 'NSD-3379 - Adding skin extensions', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2104.changeLog.xml::20210304-ps-1::paul.strugnell
-- [PL-1435] Add MS Teams session details table
CREATE TABLE vc_ms_teams_session (session_id nvarchar(15) NOT NULL, learning_id nvarchar(85) NOT NULL, sync_status char(1) NOT NULL, last_sync datetime, last_sync_uid nvarchar(85), CONSTRAINT PK_VC_MS_TEAMS_SESSION PRIMARY KEY (session_id))
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_session'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_session'; DECLARE @ColumnName SYSNAME set @ColumnName = N'session_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Primary key, Session ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_session'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_session'; DECLARE @ColumnName SYSNAME set @ColumnName = N'learning_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Learning ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_session'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_session'; DECLARE @ColumnName SYSNAME set @ColumnName = N'sync_status'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Sync Status';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_session'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_session'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_sync'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'System datetime of last sync';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_session'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_session'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_sync_uid'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'UID of last sync invoker';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

ALTER TABLE vc_ms_teams_session ADD CONSTRAINT FK_VC_MS_TEAMS_SESSION_SID FOREIGN KEY (session_id) REFERENCES cschedule (eventid)
GO

ALTER TABLE vc_ms_teams_session ADD CONSTRAINT FK_VC_MS_TEAMS_SESSION_LID FOREIGN KEY (learning_id) REFERENCES learningObject (learningid)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20210304-ps-1', 'paul.strugnell', 'nschema/2104.changeLog.xml', GETDATE(), 798, '8:f369b6d684dbf2437dddc39805b67af8', 'createTable tableName=vc_ms_teams_session; addForeignKeyConstraint baseTableName=vc_ms_teams_session, constraintName=FK_VC_MS_TEAMS_SESSION_SID, referencedTableName=cschedule; addForeignKeyConstraint baseTableName=vc_ms_teams_session, constraintNa...', '[PL-1435] Add MS Teams session details table', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2104.changeLog.xml::20210305-ps-1::paul.strugnell
-- [PL-1435] Add MS Teams meeting details table
CREATE TABLE vc_ms_teams_meeting (meeting_id nvarchar(15) NOT NULL, event_id nvarchar(15) NOT NULL, session_id nvarchar(15) NOT NULL, subject nvarchar(1000) NOT NULL, start_time datetime NOT NULL, end_time datetime NOT NULL, ms_meeting_id nvarchar(255), join_url nvarchar(1000), sync_status char(1) NOT NULL, CONSTRAINT PK_VC_MS_TEAMS_MEETING PRIMARY KEY (meeting_id))
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_meeting'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_meeting'; DECLARE @ColumnName SYSNAME set @ColumnName = N'meeting_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Primary key, Meeting ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_meeting'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_meeting'; DECLARE @ColumnName SYSNAME set @ColumnName = N'event_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Event (sub-session) ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_meeting'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_meeting'; DECLARE @ColumnName SYSNAME set @ColumnName = N'session_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Session ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_meeting'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_meeting'; DECLARE @ColumnName SYSNAME set @ColumnName = N'subject'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Meeting subject';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_meeting'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_meeting'; DECLARE @ColumnName SYSNAME set @ColumnName = N'start_time'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Meeting start time';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_meeting'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_meeting'; DECLARE @ColumnName SYSNAME set @ColumnName = N'end_time'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Meeting end time';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_meeting'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_meeting'; DECLARE @ColumnName SYSNAME set @ColumnName = N'ms_meeting_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Meeting ID from Microsoft';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_meeting'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_meeting'; DECLARE @ColumnName SYSNAME set @ColumnName = N'join_url'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Meeting join URL';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_meeting'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_meeting'; DECLARE @ColumnName SYSNAME set @ColumnName = N'sync_status'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Sync status';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

ALTER TABLE vc_ms_teams_meeting ADD CONSTRAINT FK_VC_MS_TEAMS_MEETING_EID FOREIGN KEY (event_id) REFERENCES module_session_schedule (eventid)
GO

ALTER TABLE vc_ms_teams_meeting ADD CONSTRAINT FK_VC_MS_TEAMS_MEETING_SID FOREIGN KEY (session_id) REFERENCES cschedule (eventid)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20210305-ps-1', 'paul.strugnell', 'nschema/2104.changeLog.xml', GETDATE(), 799, '8:acc7293c72d6ad03e33f5e9e5658c15f', 'createTable tableName=vc_ms_teams_meeting; addForeignKeyConstraint baseTableName=vc_ms_teams_meeting, constraintName=FK_VC_MS_TEAMS_MEETING_EID, referencedTableName=module_session_schedule; addForeignKeyConstraint baseTableName=vc_ms_teams_meeting...', '[PL-1435] Add MS Teams meeting details table', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2104.changeLog.xml::20201222-rb-1::ryan.buchanan
-- NSD-5549 - GoToTraining virtual classroom configuration - (Oauth v2)
ALTER TABLE vc_gtt_application ADD client_secret nvarchar(1000)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_gtt_application'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_gtt_application'; DECLARE @ColumnName SYSNAME set @ColumnName = N'client_secret'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'GTT Client Secret';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

exec sp_rename 'vc_gtt_application.api_key', 'client_id'
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20201222-rb-1', 'ryan.buchanan', 'nschema/2104.changeLog.xml', GETDATE(), 800, '8:22d8ef8622249028d669b548a4dfc9e8', 'addColumn tableName=vc_gtt_application; renameColumn newColumnName=client_id, oldColumnName=api_key, tableName=vc_gtt_application', 'NSD-5549 - GoToTraining virtual classroom configuration - (Oauth v2)', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2104.changeLog.xml::20210128-rn-2::ronald.ng
-- NSD-5549 - GoToTraining OAuth2 Implementation
ALTER TABLE vc_gtt_organizer ALTER COLUMN access_token nvarchar(1000)
GO

ALTER TABLE vc_gtt_organizer ADD refresh_token nvarchar(1000) NOT NULL
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_gtt_organizer'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_gtt_organizer'; DECLARE @ColumnName SYSNAME set @ColumnName = N'refresh_token'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Refresh Token for OAuth2';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20210128-rn-2', 'ronald.ng', 'nschema/2104.changeLog.xml', GETDATE(), 801, '8:90931cb7ffad7d6db7ae71a993ed4d50', 'modifyDataType columnName=access_token, tableName=vc_gtt_organizer; addColumn tableName=vc_gtt_organizer', 'NSD-5549 - GoToTraining OAuth2 Implementation', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2108.changeLog.xml::20210325-sk-1::sachin.kumar
UPDATE ekpversion SET dblevel = 2108, splevel = 0
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20210325-sk-1', 'sachin.kumar', 'nschema/2108.changeLog.xml', GETDATE(), 802, '8:0c58f38254e9bf25ea26ea862406631c', 'update tableName=ekpversion', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2108.changeLog.xml::20210526-sc-1::starry.chan
-- NSD-7447 Deadlocks in registration
INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20210526-sc-1', 'starry.chan', 'nschema/2108.changeLog.xml', GETDATE(), 803, '8:0845d445a426eaaa44764c42354c8f1a', 'dropIndex indexName=nuk_registration_user_meta_id, tableName=registration', 'NSD-7447 Deadlocks in registration', 'MARK_RAN', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2108.changeLog.xml::20210526-sc-2::starry.chan
-- NSD-7447 Deadlocks in registration
CREATE NONCLUSTERED INDEX nuk_registration_user_meta_id ON registration(user_meta_id)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20210526-sc-2', 'starry.chan', 'nschema/2108.changeLog.xml', GETDATE(), 804, '8:c3940bf79a930d7979bd17d6f3d34809', 'createIndex indexName=nuk_registration_user_meta_id, tableName=registration', 'NSD-7447 Deadlocks in registration', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2108.changeLog.xml::20210603-em-1::emmar.masagca
-- NSD-7132 Performance issues due to blocking sql in module_session_schedule
CREATE NONCLUSTERED INDEX nuk_mod_ses_sessionid ON module_session_schedule(sessionid)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20210603-em-1', 'emmar.masagca', 'nschema/2108.changeLog.xml', GETDATE(), 805, '8:0e412edf41a556db23012d802ef1c565', 'createIndex indexName=nuk_mod_ses_sessionid, tableName=module_session_schedule', 'NSD-7132 Performance issues due to blocking sql in module_session_schedule', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2108.changeLog.xml::20211014-em-1::emmar.masagca
-- NSD-7791 upgrade from 21.04.1 to 21.08.1 throws a SQLServerException and fails
DECLARE @table_id AS INT
            DECLARE @name_column_id AS INT
            DECLARE @sql nvarchar(255)

            -- Find table id
            SET @table_id = OBJECT_ID('enrollment_policy')

            -- Find name column id
            SELECT @name_column_id = column_id
            FROM sys.columns
            WHERE object_id = @table_id
              AND name = 'policyDetails'

            -- Remove default constraint from policyDetails column in enrollment_policy table if it exist
            SELECT @sql = 'ALTER TABLE enrollment_policy DROP CONSTRAINT ' + D.name
            FROM sys.default_constraints AS D
            WHERE D.parent_object_id = @table_id
              AND D.parent_column_id = @name_column_id
              EXECUTE sp_executesql @sql
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20211014-em-1', 'emmar.masagca', 'nschema/2108.changeLog.xml', GETDATE(), 806, '8:13e4e6bd4d02a5358e0c7162842375f6', 'sql', 'NSD-7791 upgrade from 21.04.1 to 21.08.1 throws a SQLServerException and fails', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2108.changeLog.xml::20220126-em-1::emmar.masagca
-- NSD-7937 Error while deploying upgrade using multiversion upgrade kit
DECLARE @table_id AS INT
            DECLARE @name_column_id AS INT
            DECLARE @sql nvarchar(255)

            -- Find table id
            SET @table_id = OBJECT_ID('cschedule')

            -- Find name column id
            SELECT @name_column_id = column_id
            FROM sys.columns
            WHERE object_id = @table_id
            AND name = 'description'

            -- Remove default constraint from description column in cschedule table if it exist
            SELECT @sql = 'ALTER TABLE cschedule DROP CONSTRAINT ' + D.name
            FROM sys.default_constraints AS D
            WHERE D.parent_object_id = @table_id
            AND D.parent_column_id = @name_column_id
            EXECUTE sp_executesql @sql
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20220126-em-1', 'emmar.masagca', 'nschema/2108.changeLog.xml', GETDATE(), 807, '8:e5150c129e2c61806afdea00bf6933ea', 'sql', 'NSD-7937 Error while deploying upgrade using multiversion upgrade kit', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2108.changeLog.xml::20210603-sk-1::sachin.kumar
-- Change the column data type to NVARCHAR(MAX) from NTEXT
ALTER TABLE AICC_Core_Vendor ALTER COLUMN core_vendor NVARCHAR(max)
GO

ALTER TABLE AICC_Core_Vendor ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE AICC_au ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE AICC_comments ALTER COLUMN comments NVARCHAR(max)
GO

ALTER TABLE AICC_core ALTER COLUMN core_lesson NVARCHAR(max)
GO

ALTER TABLE AICC_des ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE AICC_launch_options ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE ContentItem ALTER COLUMN launchData NVARCHAR(max)
GO

ALTER TABLE ContentItem ALTER COLUMN masteryScore NVARCHAR(max)
GO

ALTER TABLE ContentItem ALTER COLUMN parameters NVARCHAR(max)
GO

ALTER TABLE ContentItem ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE ContentObject ALTER COLUMN href NVARCHAR(max)
GO

ALTER TABLE ContentObject ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE ContentOrganization ALTER COLUMN title NVARCHAR(max)
GO

ALTER TABLE ContentOrganization ALTER COLUMN description NVARCHAR(max)
GO

ALTER TABLE ContentOrganization ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE ContentOrganizationKeyword ALTER COLUMN keywordText NVARCHAR(max)
GO

ALTER TABLE ContentOrganizationNode ALTER COLUMN prerequisites NVARCHAR(max)
GO

ALTER TABLE ContentOrganizationNode ALTER COLUMN title NVARCHAR(max)
GO

ALTER TABLE ContentOrganizationNode ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE ContentOrganizationObjective ALTER COLUMN description NVARCHAR(max)
GO

ALTER TABLE ContentOrganizationObjective ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE ContentPackage ALTER COLUMN filename NVARCHAR(max)
GO

ALTER TABLE ContentPackage ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE RollupCondition ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE RollupRule ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE SeqObjectiveMap ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE SeqRuleCondition ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE SequenceObjective ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE SequenceRule ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE Sequencing ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE answer_drag_and_drop ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE answer_hotspot ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE appraisal ALTER COLUMN otherAchievements NVARCHAR(max)
GO

ALTER TABLE appraisal ALTER COLUMN complianceAtt NVARCHAR(max)
GO

ALTER TABLE appraisalObjectives ALTER COLUMN area NVARCHAR(max)
GO

ALTER TABLE appraisalObjectives ALTER COLUMN response NVARCHAR(max)
GO

ALTER TABLE appraisalObjectives ALTER COLUMN appraisal_comment NVARCHAR(max)
GO

ALTER TABLE appraisal_u_career_dev ALTER COLUMN objective_desc NVARCHAR(max)
GO

ALTER TABLE appraisal_u_career_dev ALTER COLUMN how_desc NVARCHAR(max)
GO

ALTER TABLE appraisal_u_career_dev ALTER COLUMN details_desc NVARCHAR(max)
GO

ALTER TABLE appraisal_u_career_dev ALTER COLUMN measure_desc NVARCHAR(max)
GO

ALTER TABLE appraisal_u_competency ALTER COLUMN appraisee_comments NVARCHAR(max)
GO

ALTER TABLE appraisal_u_competency ALTER COLUMN appraiser_comments NVARCHAR(max)
GO

ALTER TABLE appraisal_u_dimension ALTER COLUMN appraisee_comments NVARCHAR(max)
GO

ALTER TABLE appraisal_u_dimension ALTER COLUMN appraiser_comments NVARCHAR(max)
GO

ALTER TABLE appraisal_u_free_text ALTER COLUMN entry_text NVARCHAR(max)
GO

ALTER TABLE appraisal_u_future_objective ALTER COLUMN objective_desc NVARCHAR(max)
GO

ALTER TABLE appraisal_u_future_objective ALTER COLUMN how_desc NVARCHAR(max)
GO

ALTER TABLE appraisal_u_future_objective ALTER COLUMN details_desc NVARCHAR(max)
GO

ALTER TABLE appraisal_u_goal_result ALTER COLUMN appraisee_comments NVARCHAR(max)
GO

ALTER TABLE appraisal_u_goal_result ALTER COLUMN appraiser_comments NVARCHAR(max)
GO

ALTER TABLE appraisal_u_past_objective ALTER COLUMN objective_desc NVARCHAR(max)
GO

ALTER TABLE appraisal_u_past_objective ALTER COLUMN measurement_desc NVARCHAR(max)
GO

ALTER TABLE appraisal_u_past_objective ALTER COLUMN achievement_desc NVARCHAR(max)
GO

ALTER TABLE appraisal_u_prob_sign_off ALTER COLUMN probation_extension_reason NVARCHAR(max)
GO

ALTER TABLE appraisal_u_sign_off ALTER COLUMN appraisee_comments NVARCHAR(max)
GO

ALTER TABLE appraisal_u_sign_off ALTER COLUMN appraiser_comments NVARCHAR(max)
GO

ALTER TABLE appraisal_u_sign_off ALTER COLUMN compliance_attitude NVARCHAR(max)
GO

ALTER TABLE appraisal_u_sign_off ALTER COLUMN appraisee_reply NVARCHAR(max)
GO

ALTER TABLE appraisal_u_sign_off ALTER COLUMN s_appraiser_comments NVARCHAR(max)
GO

ALTER TABLE approval_queue ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE approval_queue_step ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE article ALTER COLUMN text1 NVARCHAR(max)
GO

ALTER TABLE audience ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE autoenroll ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE autoenroll_trace ALTER COLUMN message NVARCHAR(max)
GO

ALTER TABLE background_task_log ALTER COLUMN parameters NVARCHAR(max)
GO

ALTER TABLE background_task_log ALTER COLUMN messages NVARCHAR(max)
GO

ALTER TABLE background_task_progress ALTER COLUMN progress_data NVARCHAR(max)
GO

ALTER TABLE bg_task_to_be_merged_log ALTER COLUMN parameters NVARCHAR(max)
GO

ALTER TABLE cert_renewal ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE certifications ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE certusers ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE certusers ALTER COLUMN course_module_description NVARCHAR(max)
GO

ALTER TABLE class_resource_attribute ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE code_orgstructure ALTER COLUMN imprint NVARCHAR(max)
GO

ALTER TABLE code_orgstructure ALTER COLUMN esig_course_csv_loader_meaning NVARCHAR(max)
GO

ALTER TABLE code_orgstructure ALTER COLUMN esig_prog_csv_loader_meaning NVARCHAR(max)
GO

ALTER TABLE code_orgstructure ALTER COLUMN esig_course_withdraw_meaning NVARCHAR(max)
GO

ALTER TABLE code_orgstructure ALTER COLUMN esig_course_modify_meaning NVARCHAR(max)
GO

ALTER TABLE code_orgstructure ALTER COLUMN esig_course_launch_meaning NVARCHAR(max)
GO

ALTER TABLE code_orgstructure ALTER COLUMN esig_course_import_meaning NVARCHAR(max)
GO

ALTER TABLE code_orgstructure ALTER COLUMN esig_course_finish_meaning NVARCHAR(max)
GO

ALTER TABLE code_orgstructure ALTER COLUMN esig_exam_launch_meaning NVARCHAR(max)
GO

ALTER TABLE code_orgstructure ALTER COLUMN esig_question_mod_meaning NVARCHAR(max)
GO

ALTER TABLE code_orgstructure ALTER COLUMN esig_question_import_meaning NVARCHAR(max)
GO

ALTER TABLE code_orgstructure ALTER COLUMN esig_grading_test_ans_meaning NVARCHAR(max)
GO

ALTER TABLE code_orgstructure ALTER COLUMN esig_review_mod_trans_meaning NVARCHAR(max)
GO

ALTER TABLE code_orgstructure ALTER COLUMN esig_editor_mod_trans_meaning NVARCHAR(max)
GO

ALTER TABLE code_orgstructure ALTER COLUMN esig_mod_attendance_meaning NVARCHAR(max)
GO

ALTER TABLE code_orgstructure ALTER COLUMN esig_wizard_mod_trans_meaning NVARCHAR(max)
GO

ALTER TABLE code_orgstructure ALTER COLUMN esig_mod_ext_training_meaning NVARCHAR(max)
GO

ALTER TABLE code_orgstructure ALTER COLUMN esig_mod_cert_meaning NVARCHAR(max)
GO

ALTER TABLE code_orgstructure ALTER COLUMN esig_award_revert_cert_meaning NVARCHAR(max)
GO

ALTER TABLE code_orgstructure ALTER COLUMN esig_equi_rule_meaning NVARCHAR(max)
GO

ALTER TABLE code_role ALTER COLUMN description NVARCHAR(max)
GO

ALTER TABLE code_training_resource ALTER COLUMN description NVARCHAR(max)
GO

ALTER TABLE column_preset ALTER COLUMN preset_data NVARCHAR(max)
GO

ALTER TABLE comp_analysis_history_groups ALTER COLUMN group_name NVARCHAR(max)
GO

ALTER TABLE comp_analysis_history_overall ALTER COLUMN input_parameters NVARCHAR(max)
GO

ALTER TABLE comp_analysis_history_users ALTER COLUMN group_name NVARCHAR(max)
GO

ALTER TABLE comp_approval_queue ALTER COLUMN approver_remarks NVARCHAR(max)
GO

ALTER TABLE comp_approval_queue ALTER COLUMN requester_remarks NVARCHAR(max)
GO

ALTER TABLE comp_assess_participant_eval ALTER COLUMN evidence NVARCHAR(max)
GO

ALTER TABLE comp_assess_user_participant ALTER COLUMN overall_comments NVARCHAR(max)
GO

ALTER TABLE competency_assessment ALTER COLUMN desc_text NVARCHAR(max)
GO

ALTER TABLE competency_assessment ALTER COLUMN instr_text NVARCHAR(max)
GO

ALTER TABLE competency_assessment_template ALTER COLUMN desc_text NVARCHAR(max)
GO

ALTER TABLE competency_assessment_template ALTER COLUMN instr_text NVARCHAR(max)
GO

ALTER TABLE competency_level ALTER COLUMN desc_text NVARCHAR(max)
GO

ALTER TABLE competency_level ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE contactList ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE content_org_node_objective ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE course ALTER COLUMN launchpage NVARCHAR(max)
GO

ALTER TABLE course ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE courseAccessLevel ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE courseAccessUser ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE courseDownloads ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE course_bundle ALTER COLUMN launchpage NVARCHAR(max)
GO

ALTER TABLE course_competency ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE course_revision ALTER COLUMN revision_comment NVARCHAR(max)
GO

ALTER TABLE course_revision ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE course_session_cost ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE coursetest ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE cschedule ALTER COLUMN description NVARCHAR(max)
GO

ALTER TABLE cschedule ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE currcourses ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE current_progress_status ALTER COLUMN substitute_modules NVARCHAR(max)
GO

ALTER TABLE curriculum ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE custom_course_policy ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE draggable ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE email_profile_detail ALTER COLUMN body NVARCHAR(max)
GO

ALTER TABLE enrollment_policy ALTER COLUMN policyDetails NVARCHAR(max)
GO

ALTER TABLE enrollment_policy ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE enrollment_policy_step ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE evaluation ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE ex_q_approval ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE exam_comment ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE exam_comment ALTER COLUMN commenttext NVARCHAR(max)
GO

ALTER TABLE exam_workflow ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE exam_workflow_step ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE extended_enrollment_details ALTER COLUMN comments NVARCHAR(max)
GO

ALTER TABLE external_training ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE get_abstract_launcher ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE globalenglish_launcher ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE goal ALTER COLUMN description NVARCHAR(max)
GO

ALTER TABLE goal_development ALTER COLUMN measurement NVARCHAR(max)
GO

ALTER TABLE goal_personal ALTER COLUMN measurement NVARCHAR(max)
GO

ALTER TABLE goal_program ALTER COLUMN description NVARCHAR(max)
GO

ALTER TABLE goal_tracking ALTER COLUMN result_to_date NVARCHAR(max)
GO

ALTER TABLE holiday_date ALTER COLUMN description NVARCHAR(max)
GO

ALTER TABLE homework_file ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE hotspot ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE iComment ALTER COLUMN commenttext NVARCHAR(max)
GO

ALTER TABLE iComment ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE individual_competency ALTER COLUMN description NVARCHAR(max)
GO

ALTER TABLE individual_competency ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE job_profile ALTER COLUMN description NVARCHAR(max)
GO

ALTER TABLE job_profile ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE job_profile_competency ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE jobprofile_autoenroll ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE knowledgecenteroptions ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE learningObject ALTER COLUMN description1 NVARCHAR(max)
GO

ALTER TABLE learningObject ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE learningObject ALTER COLUMN esig_course_withdraw_meaning NVARCHAR(max)
GO

ALTER TABLE learningObject ALTER COLUMN esig_course_modify_meaning NVARCHAR(max)
GO

ALTER TABLE learningObject ALTER COLUMN esig_course_launch_meaning NVARCHAR(max)
GO

ALTER TABLE learningObject ALTER COLUMN esig_course_import_meaning NVARCHAR(max)
GO

ALTER TABLE learningObject ALTER COLUMN esig_course_finish_meaning NVARCHAR(max)
GO

ALTER TABLE learningObject ALTER COLUMN esig_exam_launch_meaning NVARCHAR(max)
GO

ALTER TABLE learningObject ALTER COLUMN esig_wzrd_modify_trans_meaning NVARCHAR(max)
GO

ALTER TABLE learningObject ALTER COLUMN esig_rvwr_modify_trans_meaning NVARCHAR(max)
GO

ALTER TABLE learningObject ALTER COLUMN esig_edtr_modify_trans_meaning NVARCHAR(max)
GO

ALTER TABLE learningObject ALTER COLUMN esig_modify_attendance_meaning NVARCHAR(max)
GO

ALTER TABLE learningObject ALTER COLUMN esig_equi_rule_meaning NVARCHAR(max)
GO

ALTER TABLE learningObjectKeyword ALTER COLUMN keywordText NVARCHAR(max)
GO

ALTER TABLE lo_attribute ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE lo_opt_pay_items ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE locosts ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE logical_domain_config ALTER COLUMN config_value NVARCHAR(max)
GO

ALTER TABLE lp_session_cost ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE masterquestion ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE mastersection ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE mastertest ALTER COLUMN longDescription NVARCHAR(max)
GO

ALTER TABLE mastertest ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE mastertest_print ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE module_session_schedule ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE msgContent ALTER COLUMN text1 NVARCHAR(max)
GO

ALTER TABLE netassessor_launcher ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE netg_proxied_authentication ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE notepad ALTER COLUMN notetext NVARCHAR(max)
GO

ALTER TABLE objectives_topics ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE opml_task_log ALTER COLUMN error_exceptions NVARCHAR(max)
GO

ALTER TABLE opml_task_log ALTER COLUMN warning_exceptions NVARCHAR(max)
GO

ALTER TABLE otherObjects ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE owners ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE payment ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE peerComments ALTER COLUMN description1 NVARCHAR(max)
GO

ALTER TABLE pending_mail ALTER COLUMN to_users NVARCHAR(max)
GO

ALTER TABLE pending_mail ALTER COLUMN cc_users NVARCHAR(max)
GO

ALTER TABLE pending_mail ALTER COLUMN content NVARCHAR(max)
GO

ALTER TABLE pending_mail ALTER COLUMN bcc_users NVARCHAR(max)
GO

ALTER TABLE personal_event ALTER COLUMN description NVARCHAR(max)
GO

ALTER TABLE prereq ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE qattributes ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE question ALTER COLUMN hint NVARCHAR(max)
GO

ALTER TABLE question ALTER COLUMN prenote NVARCHAR(max)
GO

ALTER TABLE question ALTER COLUMN postnote NVARCHAR(max)
GO

ALTER TABLE question ALTER COLUMN qtext NVARCHAR(max)
GO

ALTER TABLE question ALTER COLUMN plain_text NVARCHAR(max)
GO

ALTER TABLE question ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE question_type1 ALTER COLUMN qtext2 NVARCHAR(max)
GO

ALTER TABLE question_type1 ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE question_type2 ALTER COLUMN qtext2 NVARCHAR(max)
GO

ALTER TABLE question_type2 ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE question_type3 ALTER COLUMN qtext2 NVARCHAR(max)
GO

ALTER TABLE question_type3 ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE question_type4 ALTER COLUMN qtext2 NVARCHAR(max)
GO

ALTER TABLE question_type4 ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE question_type5 ALTER COLUMN qtext2 NVARCHAR(max)
GO

ALTER TABLE question_type5 ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE question_type6 ALTER COLUMN qtext2 NVARCHAR(max)
GO

ALTER TABLE question_type6 ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE question_type7 ALTER COLUMN qtext1 NVARCHAR(max)
GO

ALTER TABLE question_type7 ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE question_type8 ALTER COLUMN qtext NVARCHAR(max)
GO

ALTER TABLE question_type8 ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE question_type8_item ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE question_type9 ALTER COLUMN qtext2 NVARCHAR(max)
GO

ALTER TABLE question_type9 ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE question_type_drag_and_drop ALTER COLUMN qtext NVARCHAR(max)
GO

ALTER TABLE question_type_drag_and_drop ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE question_type_hotspot ALTER COLUMN qtext NVARCHAR(max)
GO

ALTER TABLE question_type_hotspot ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE randsection ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE registeredevents ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE registration ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE report_security ALTER COLUMN permission NVARCHAR(max)
GO

ALTER TABLE report_wizard ALTER COLUMN join_sql NVARCHAR(max)
GO

ALTER TABLE report_wizard ALTER COLUMN custom_filter NVARCHAR(max)
GO

ALTER TABLE reports ALTER COLUMN html NVARCHAR(max)
GO

ALTER TABLE resource_planner_defaults ALTER COLUMN working_period NVARCHAR(max)
GO

ALTER TABLE resource_planner_defaults ALTER COLUMN display_fields NVARCHAR(max)
GO

ALTER TABLE resource_string ALTER COLUMN value_ntext NVARCHAR(max)
GO

ALTER TABLE safari_launcher ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE schedule_report ALTER COLUMN parameters NVARCHAR(max)
GO

ALTER TABLE session_attribute ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE session_cost ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE sessiondetail ALTER COLUMN description NVARCHAR(max)
GO

ALTER TABLE sessiondetail ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE task_signoff_config ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE task_signoff_users ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE template_widget_html_config ALTER COLUMN content NVARCHAR(max)
GO

ALTER TABLE template_widget_html_preset ALTER COLUMN content NVARCHAR(max)
GO

ALTER TABLE terms_of_use ALTER COLUMN accept_label NVARCHAR(max)
GO

ALTER TABLE terms_of_use ALTER COLUMN text NVARCHAR(max)
GO

ALTER TABLE testinstance ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE testquestion ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE testquestion3 ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE testquestion4 ALTER COLUMN text1 NVARCHAR(max)
GO

ALTER TABLE testquestion4 ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE testquestion5 ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE testquestion6 ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE testquestion8 ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE testquestion9 ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE testsection ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE tincan_statement ALTER COLUMN json NVARCHAR(max)
GO

ALTER TABLE tincan_statement_action_info ALTER COLUMN content NVARCHAR(max)
GO

ALTER TABLE tms_responsibility_level ALTER COLUMN desc_text NVARCHAR(max)
GO

ALTER TABLE tms_responsibility_level ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE transcript ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE transcript_attribute ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE transcript_stat_log ALTER COLUMN comments NVARCHAR(max)
GO

ALTER TABLE tutor ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE user_competency ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE user_group ALTER COLUMN group_description NVARCHAR(max)
GO

ALTER TABLE user_job_profile ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE user_opt_pay_items ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE user_profile_work_history ALTER COLUMN achievements NVARCHAR(max)
GO

ALTER TABLE user_profile_work_history ALTER COLUMN awards NVARCHAR(max)
GO

ALTER TABLE userbio_assignment ALTER COLUMN bio NVARCHAR(max)
GO

ALTER TABLE userbio_assignment ALTER COLUMN bio_work_experience NVARCHAR(max)
GO

ALTER TABLE userbio_assignment ALTER COLUMN bio_edu_background NVARCHAR(max)
GO

ALTER TABLE userbio_assignment ALTER COLUMN bio_interests NVARCHAR(max)
GO

ALTER TABLE users_meta ALTER COLUMN reloc_reason NVARCHAR(max)
GO

ALTER TABLE users_meta ALTER COLUMN other_info NVARCHAR(max)
GO

ALTER TABLE vc_launcher_generic ALTER COLUMN launch_url NVARCHAR(max)
GO

ALTER TABLE vc_launcher_generic ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE vc_launcher_gtt ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE vc_launcher_gtt_organizer ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE vc_launcher_gtt_training ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE vc_launcher_ms_teams ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE vc_launcher_session ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE vc_launcher_vitero ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE vc_launcher_webex ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE vc_vitero_sync_log ALTER COLUMN params NVARCHAR(max)
GO

ALTER TABLE wiki_interaction_log ALTER COLUMN call_param NVARCHAR(max)
GO

ALTER TABLE wiki_interaction_log ALTER COLUMN error_msg NVARCHAR(max)
GO

ALTER TABLE withdraw_ded_fixed_amount ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE withdraw_ded_opt_pay_items ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE withdraw_deduction ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE withdraw_reason ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

ALTER TABLE withdrawnStudents ALTER COLUMN update_meaning_text NVARCHAR(max)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20210603-sk-1', 'sachin.kumar', 'nschema/2108.changeLog.xml', GETDATE(), 808, '8:723e27ececb4b04ddc24516738f50644', 'sql', 'Change the column data type to NVARCHAR(MAX) from NTEXT', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2108.changeLog.xml::20210611-sc-1::shu.cui
-- NSD-6871 Enhance table exchange_server_login to store both basic and oauth2 login information
ALTER TABLE exchange_server_login ALTER COLUMN password nvarchar(255) NULL
GO

ALTER TABLE exchange_server_login ADD tenant_id nvarchar(255)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'exchange_server_login'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.exchange_server_login'; DECLARE @ColumnName SYSNAME set @ColumnName = N'tenant_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Tenant ID from Microsoft';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

ALTER TABLE exchange_server_login ADD client_id nvarchar(255)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'exchange_server_login'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.exchange_server_login'; DECLARE @ColumnName SYSNAME set @ColumnName = N'client_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Client ID from Microsoft';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

ALTER TABLE exchange_server_login ADD client_secret nvarchar(255)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'exchange_server_login'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.exchange_server_login'; DECLARE @ColumnName SYSNAME set @ColumnName = N'client_secret'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Client Secret from Microsoft';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20210611-sc-1', 'shu.cui', 'nschema/2108.changeLog.xml', GETDATE(), 809, '8:f5b508b982bcde105feb0718f5327c36', 'dropNotNullConstraint columnName=password, tableName=exchange_server_login; addColumn tableName=exchange_server_login; addColumn tableName=exchange_server_login; addColumn tableName=exchange_server_login', 'NSD-6871 Enhance table exchange_server_login to store both basic and oauth2 login information', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2108.changeLog.xml::20210630-ps-1::paul.strugnell
-- NSD-7549: add INCLUDE columns to index nuk_withdrawn on withdrawnStudents table (MSSQL only)
DROP INDEX nuk_withdrawn ON withdrawnStudents
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20210630-ps-1', 'paul.strugnell', 'nschema/2108.changeLog.xml', GETDATE(), 810, '8:dd5a5fd0db91989f349b66b2cce06fa3', 'dropIndex indexName=nuk_withdrawn, tableName=withdrawnStudents', 'NSD-7549: add INCLUDE columns to index nuk_withdrawn on withdrawnStudents table (MSSQL only)', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2108.changeLog.xml::20210630-ps-2::paul.strugnell
-- NSD-7549: add INCLUDE columns to index nuk_withdrawn on withdrawnStudents table (MSSQL only)
CREATE NONCLUSTERED INDEX nuk_withdrawn
            ON withdrawnStudents (learningid, eventid)
            INCLUDE (id, userid, transcriptid, datecreated, studentstatus, bundle_id)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20210630-ps-2', 'paul.strugnell', 'nschema/2108.changeLog.xml', GETDATE(), 811, '8:984c7915472cc6cc8d3f66a5810ab13c', 'sql', 'NSD-7549: add INCLUDE columns to index nuk_withdrawn on withdrawnStudents table (MSSQL only)', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2111.changeLog.xml::20210715-rb-1::ryan.buchanan
UPDATE ekpversion SET dblevel = 2111, splevel = 0
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20210715-rb-1', 'ryan.buchanan', 'nschema/2111.changeLog.xml', GETDATE(), 812, '8:1c2112ea7668345ba32b9e69a1886da3', 'update tableName=ekpversion', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2111.changeLog.xml::20210825-yf-1::yueqin.feng
-- PL-1742: Modify skin functionality to designate colors for new UI via skin.properties
ALTER TABLE screenLayout ADD primary_color nvarchar(9)
GO

ALTER TABLE screenLayout ADD secondary_color nvarchar(9)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'screenLayout'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.screenLayout'; DECLARE @ColumnName SYSNAME set @ColumnName = N'primary_color'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'primary color, used for the new UI masthead and buttons, e.g. #00000000';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'screenLayout'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.screenLayout'; DECLARE @ColumnName SYSNAME set @ColumnName = N'secondary_color'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'secondary color, used for the new UI navigation, e.g. #00000000';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

UPDATE screenLayout SET primary_color = '#1565c0', secondary_color = '#333' WHERE shortname='PeopleFluent_LMS_Default' AND directory='lms-skin'
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20210825-yf-1', 'yueqin.feng', 'nschema/2111.changeLog.xml', GETDATE(), 813, '8:f62b8ba42ba1542bc9087b6aed59dd61', 'addColumn tableName=screenLayout; update tableName=screenLayout', 'PL-1742: Modify skin functionality to designate colors for new UI via skin.properties', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2111.changeLog.xml::20210914-ct-4::craig.taylor
-- PL-2355: Rustici property settings
CREATE TABLE rustici_property (name nvarchar(48) NOT NULL, display_order numeric(8, 0) NOT NULL, rustici_prop_group_name nvarchar(85) NOT NULL, render_type nvarchar(16) NOT NULL, render_attributes nvarchar(4000))
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'rustici_property'; DECLARE @FullTableName SYSNAME; SET @FullTableName = @DynamicSchemaName + N'.rustici_property';DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Rustici property definitions';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.name = N'MS_Description' AND ep.minor_id=0); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'rustici_property'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.rustici_property'; DECLARE @ColumnName SYSNAME set @ColumnName = N'name'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Rustici property name';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'rustici_property'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.rustici_property'; DECLARE @ColumnName SYSNAME set @ColumnName = N'display_order'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Display rendering order within the group (0=highest)';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'rustici_property'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.rustici_property'; DECLARE @ColumnName SYSNAME set @ColumnName = N'rustici_prop_group_name'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Group this property definition belongs in';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'rustici_property'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.rustici_property'; DECLARE @ColumnName SYSNAME set @ColumnName = N'render_type'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Internal LMS Rendering type';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'rustici_property'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.rustici_property'; DECLARE @ColumnName SYSNAME set @ColumnName = N'render_attributes'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Internal LMS definition of attributes for the rendering type';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

ALTER TABLE rustici_property ADD CONSTRAINT pk_rustici_property PRIMARY KEY (name)
GO

CREATE TABLE rustici_property_group (name nvarchar(128) NOT NULL, display_order numeric(8, 0) NOT NULL)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'rustici_property_group'; DECLARE @FullTableName SYSNAME; SET @FullTableName = @DynamicSchemaName + N'.rustici_property_group';DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Rustici property group';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.name = N'MS_Description' AND ep.minor_id=0); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'rustici_property_group'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.rustici_property_group'; DECLARE @ColumnName SYSNAME set @ColumnName = N'name'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Will used rustici+_+[this.name] label for display';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'rustici_property_group'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.rustici_property_group'; DECLARE @ColumnName SYSNAME set @ColumnName = N'display_order'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Display rendering order for the group (0=highest)';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

ALTER TABLE rustici_property_group ADD CONSTRAINT pk_rustici_propgrp PRIMARY KEY (name)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20210914-ct-4', 'craig.taylor', 'nschema/2111.changeLog.xml', GETDATE(), 814, '8:379dd879512ddf2126d053767e34424a', 'createTable tableName=rustici_property; addPrimaryKey constraintName=pk_rustici_property, tableName=rustici_property; createTable tableName=rustici_property_group; addPrimaryKey constraintName=pk_rustici_propgrp, tableName=rustici_property_group', 'PL-2355: Rustici property settings', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2111.changeLog.xml::20210929-js-1::michael.gorohov
-- Add account_type and content_connector_prefix columns to the olsa_account table
ALTER TABLE olsa_account ADD account_type nvarchar(127) CONSTRAINT DF_olsa_account_account_type DEFAULT 'Skillsoft' NOT NULL
GO

ALTER TABLE olsa_account ADD content_connector_prefix nvarchar(127)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'olsa_account'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.olsa_account'; DECLARE @ColumnName SYSNAME set @ColumnName = N'account_type'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Used to specify Web Catalog''s accout type';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'olsa_account'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.olsa_account'; DECLARE @ColumnName SYSNAME set @ColumnName = N'content_connector_prefix'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Used to specify Content Connector''s prefix';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20210929-js-1', 'michael.gorohov', 'nschema/2111.changeLog.xml', GETDATE(), 815, '8:6697a22fae5498d0570cc1cd5e41b93c', 'addColumn tableName=olsa_account', 'Add account_type and content_connector_prefix columns to the olsa_account table', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2111.changeLog.xml::20211004-ct-4::craig.taylor
INSERT INTO rustici_property_group (name, display_order) VALUES ('launchSettings', '1')
GO

INSERT INTO rustici_property_group (name, display_order) VALUES ('navigationSettings', '2')
GO

INSERT INTO rustici_property_group (name, display_order) VALUES ('compatibilitySettings', '3')
GO

INSERT INTO rustici_property (name, display_order, rustici_prop_group_name, render_type, render_attributes) VALUES ('PlayerScoLaunchType', '1', 'launchSettings', 'selector', 'FRAMESET,NEW_WINDOW,NEW_WINDOW_AFTER_CLICK,NEW_WINDOW_WITHOUT_BROWSER_TOOLBAR,NEW_WINDOW_AFTER_CLICK_WITHOUT_BROWSER_TOOLBAR')
GO

INSERT INTO rustici_property (name, display_order, rustici_prop_group_name, render_type, render_attributes) VALUES ('PlayerLaunchType', '2', 'launchSettings', 'selector', 'FRAMESET,NEW_WINDOW,NEW_WINDOW_AFTER_CLICK,NEW_WINDOW_WITHOUT_BROWSER_TOOLBAR,NEW_WINDOW_AFTER_CLICK_WITHOUT_BROWSER_TOOLBAR')
GO

INSERT INTO rustici_property (name, display_order, rustici_prop_group_name, render_type) VALUES ('PlayerShowFinishButton', '1', 'navigationSettings', 'boolean')
GO

INSERT INTO rustici_property (name, display_order, rustici_prop_group_name, render_type) VALUES ('PlayerShowNavBar', '2', 'navigationSettings', 'boolean')
GO

INSERT INTO rustici_property (name, display_order, rustici_prop_group_name, render_type) VALUES ('PlayerWrapScoWindowWithApi', '1', 'compatibilitySettings', 'boolean')
GO

INSERT INTO rustici_property (name, display_order, rustici_prop_group_name, render_type, render_attributes) VALUES ('PlayerFinishCausesImmediateCommit', '2', 'compatibilitySettings', 'boolean', '')
GO

INSERT INTO rustici_property (name, display_order, rustici_prop_group_name, render_type) VALUES ('PlayerValidateInteractionResponses', '3', 'compatibilitySettings', 'boolean')
GO

INSERT INTO rustici_property (name, display_order, rustici_prop_group_name, render_type) VALUES ('PlayerScoreOverridesStatus', '4', 'compatibilitySettings', 'boolean')
GO

INSERT INTO rustici_property (name, display_order, rustici_prop_group_name, render_type) VALUES ('PlayerScaleRawScore', '5', 'compatibilitySettings', 'boolean')
GO

INSERT INTO rustici_property (name, display_order, rustici_prop_group_name, render_type) VALUES ('PlayerRollupEmptySetToUnknown', '6', 'compatibilitySettings', 'boolean')
GO

INSERT INTO rustici_property (name, display_order, rustici_prop_group_name, render_type, render_attributes) VALUES ('PlayerReturnToLmsAction', '7', 'compatibilitySettings', 'selector', 'Legacy,SuspendAll,ExitAll,Selectable')
GO

INSERT INTO rustici_property (name, display_order, rustici_prop_group_name, render_type) VALUES ('PlayerRollupRuntimeAtScoUnload', '8', 'compatibilitySettings', 'boolean')
GO

INSERT INTO rustici_property (name, display_order, rustici_prop_group_name, render_type) VALUES ('PlayerForceObjectiveCompletionSetByContent', '9', 'compatibilitySettings', 'boolean')
GO

INSERT INTO rustici_property (name, display_order, rustici_prop_group_name, render_type) VALUES ('PlayerInvokeRollupAtSuspendAll', '10', 'compatibilitySettings', 'boolean')
GO

INSERT INTO rustici_property (name, display_order, rustici_prop_group_name, render_type) VALUES ('PlayerSuspendDataMaxLength', '11', 'compatibilitySettings', 'text')
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20211004-ct-4', 'craig.taylor', 'nschema/2111.changeLog.xml', GETDATE(), 816, '8:648a5922fdb50ee172d47210c45286a4', 'insert tableName=rustici_property_group; insert tableName=rustici_property_group; insert tableName=rustici_property_group; insert tableName=rustici_property; insert tableName=rustici_property; insert tableName=rustici_property; insert tableName=ru...', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2203.changeLog.xml::20211028-sc-1::shu.cui
UPDATE ekpversion SET dblevel = 2203, splevel = 0
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20211028-sc-1', 'shu.cui', 'nschema/2203.changeLog.xml', GETDATE(), 817, '8:155407162ebe8334947378a6efd34cee', 'update tableName=ekpversion', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2203.changeLog.xml::20211210-em-1::emmar.masagca
-- PL-2823 Apply recommended Indexes to 22.03
CREATE NONCLUSTERED INDEX IDX_courseid_eventid ON currcourses(courseid, eventid)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20211210-em-1', 'emmar.masagca', 'nschema/2203.changeLog.xml', GETDATE(), 818, '8:8f4a756d37eea1d1580319814f38f903', 'createIndex indexName=IDX_courseid_eventid, tableName=currcourses', 'PL-2823 Apply recommended Indexes to 22.03', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2203.changeLog.xml::20211210-em-2::emmar.masagca
-- PL-2823 Apply recommended Indexes to 22.03
CREATE NONCLUSTERED INDEX NUK_currcourses_required ON currcourses(required)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20211210-em-2', 'emmar.masagca', 'nschema/2203.changeLog.xml', GETDATE(), 819, '8:08d3df707fe58d236ce4a03cd7256c32', 'createIndex indexName=NUK_currcourses_required, tableName=currcourses', 'PL-2823 Apply recommended Indexes to 22.03', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2203.changeLog.xml::20211210-em-3::emmar.masagca
-- PL-2823 Apply recommended Indexes to 22.03
CREATE NONCLUSTERED INDEX NUK_auditobj_action_type_id
            ON auditobjects (action, objecttype, objectid)
            INCLUDE (actiontime)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20211210-em-3', 'emmar.masagca', 'nschema/2203.changeLog.xml', GETDATE(), 820, '8:d9b0b568dac63b444118869eadb5e92c', 'sql', 'PL-2823 Apply recommended Indexes to 22.03', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2203.changeLog.xml::20211210-em-4::emmar.masagca
-- PL-2823 Apply recommended Indexes to 22.03
CREATE NONCLUSTERED INDEX NUK_tran_eid_currid_status
            ON transcript (eventid,currid,studentstatus)
            INCLUDE (confirmation_status,
            completion_deadline,allowDappraiserAssess,allowSupervisorAssess,
            student_substatus,bundle_id,reserve_seat)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20211210-em-4', 'emmar.masagca', 'nschema/2203.changeLog.xml', GETDATE(), 821, '8:833edabfad0d3a199e73946eab6953d3', 'sql', 'PL-2823 Apply recommended Indexes to 22.03', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/liquibase.quartz.init.xml::quartz-init::quartz
CREATE TABLE QRTZ_LOCKS (SCHED_NAME varchar(120) NOT NULL, LOCK_NAME varchar(40) NOT NULL)
GO

ALTER TABLE QRTZ_LOCKS ADD PRIMARY KEY (SCHED_NAME, LOCK_NAME)
GO

CREATE TABLE QRTZ_FIRED_TRIGGERS (SCHED_NAME varchar(120) NOT NULL, ENTRY_ID varchar(95) NOT NULL, TRIGGER_NAME varchar(200) NOT NULL, TRIGGER_GROUP varchar(200) NOT NULL, INSTANCE_NAME varchar(200) NOT NULL, FIRED_TIME bigint NOT NULL, SCHED_TIME bigint NOT NULL, PRIORITY int NOT NULL, STATE varchar(16) NOT NULL, JOB_NAME varchar(200), JOB_GROUP varchar(200), IS_NONCONCURRENT bit, REQUESTS_RECOVERY bit)
GO

ALTER TABLE QRTZ_FIRED_TRIGGERS ADD PRIMARY KEY (SCHED_NAME, ENTRY_ID)
GO

CREATE NONCLUSTERED INDEX IDX_QRTZ_FT_INST_JOB_REQ_RCVRY ON QRTZ_FIRED_TRIGGERS(SCHED_NAME, INSTANCE_NAME, REQUESTS_RECOVERY)
GO

CREATE NONCLUSTERED INDEX IDX_QRTZ_FT_J_G ON QRTZ_FIRED_TRIGGERS(SCHED_NAME, JOB_NAME, JOB_GROUP)
GO

CREATE NONCLUSTERED INDEX IDX_QRTZ_FT_JG ON QRTZ_FIRED_TRIGGERS(SCHED_NAME, JOB_GROUP)
GO

CREATE NONCLUSTERED INDEX IDX_QRTZ_FT_T_G ON QRTZ_FIRED_TRIGGERS(SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP)
GO

CREATE NONCLUSTERED INDEX IDX_QRTZ_FT_TG ON QRTZ_FIRED_TRIGGERS(SCHED_NAME, TRIGGER_GROUP)
GO

CREATE NONCLUSTERED INDEX IDX_QRTZ_FT_TRIG_INST_NAME ON QRTZ_FIRED_TRIGGERS(SCHED_NAME, INSTANCE_NAME)
GO

CREATE TABLE QRTZ_CALENDARS (SCHED_NAME varchar(120) NOT NULL, CALENDAR_NAME varchar(200) NOT NULL, CALENDAR varbinary(MAX) NOT NULL)
GO

ALTER TABLE QRTZ_CALENDARS ADD PRIMARY KEY (SCHED_NAME, CALENDAR_NAME)
GO

CREATE TABLE QRTZ_PAUSED_TRIGGER_GRPS (SCHED_NAME varchar(120) NOT NULL, TRIGGER_GROUP varchar(200) NOT NULL)
GO

ALTER TABLE QRTZ_PAUSED_TRIGGER_GRPS ADD PRIMARY KEY (SCHED_NAME, TRIGGER_GROUP)
GO

CREATE TABLE QRTZ_SCHEDULER_STATE (SCHED_NAME varchar(120) NOT NULL, INSTANCE_NAME varchar(200) NOT NULL, LAST_CHECKIN_TIME bigint NOT NULL, CHECKIN_INTERVAL bigint NOT NULL)
GO

ALTER TABLE QRTZ_SCHEDULER_STATE ADD PRIMARY KEY (SCHED_NAME, INSTANCE_NAME)
GO

CREATE TABLE QRTZ_JOB_DETAILS (SCHED_NAME varchar(120) NOT NULL, JOB_NAME varchar(200) NOT NULL, JOB_GROUP varchar(200) NOT NULL, DESCRIPTION varchar(250), JOB_CLASS_NAME varchar(250) NOT NULL, IS_DURABLE bit NOT NULL, IS_NONCONCURRENT bit NOT NULL, IS_UPDATE_DATA bit NOT NULL, REQUESTS_RECOVERY bit NOT NULL, JOB_DATA varbinary(MAX))
GO

ALTER TABLE QRTZ_JOB_DETAILS ADD PRIMARY KEY (SCHED_NAME, JOB_NAME, JOB_GROUP)
GO

CREATE NONCLUSTERED INDEX IDX_QRTZ_J_GRP ON QRTZ_JOB_DETAILS(SCHED_NAME, JOB_GROUP)
GO

CREATE NONCLUSTERED INDEX IDX_QRTZ_J_REQ_RECOVERY ON QRTZ_JOB_DETAILS(SCHED_NAME, REQUESTS_RECOVERY)
GO

CREATE TABLE QRTZ_TRIGGERS (SCHED_NAME varchar(120) NOT NULL, TRIGGER_NAME varchar(200) NOT NULL, TRIGGER_GROUP varchar(200) NOT NULL, JOB_NAME varchar(200) NOT NULL, JOB_GROUP varchar(200) NOT NULL, DESCRIPTION varchar(250), NEXT_FIRE_TIME bigint, PREV_FIRE_TIME bigint, PRIORITY int, TRIGGER_STATE varchar(16) NOT NULL, TRIGGER_TYPE varchar(8) NOT NULL, START_TIME bigint NOT NULL, END_TIME bigint, CALENDAR_NAME varchar(200), MISFIRE_INSTR smallint, JOB_DATA varbinary(MAX))
GO

ALTER TABLE QRTZ_TRIGGERS ADD PRIMARY KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP)
GO

CREATE NONCLUSTERED INDEX IDX_QRTZ_T_C ON QRTZ_TRIGGERS(SCHED_NAME, CALENDAR_NAME)
GO

CREATE NONCLUSTERED INDEX IDX_QRTZ_T_G ON QRTZ_TRIGGERS(SCHED_NAME, TRIGGER_GROUP)
GO

CREATE NONCLUSTERED INDEX IDX_QRTZ_T_JG ON QRTZ_TRIGGERS(SCHED_NAME, JOB_GROUP)
GO

CREATE NONCLUSTERED INDEX IDX_QRTZ_T_N_G_STATE ON QRTZ_TRIGGERS(SCHED_NAME, TRIGGER_GROUP, TRIGGER_STATE)
GO

CREATE NONCLUSTERED INDEX IDX_QRTZ_T_N_STATE ON QRTZ_TRIGGERS(SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP, TRIGGER_STATE)
GO

CREATE NONCLUSTERED INDEX IDX_QRTZ_T_NEXT_FIRE_TIME ON QRTZ_TRIGGERS(SCHED_NAME, NEXT_FIRE_TIME)
GO

CREATE NONCLUSTERED INDEX IDX_QRTZ_T_NFT_MISFIRE ON QRTZ_TRIGGERS(SCHED_NAME, MISFIRE_INSTR, NEXT_FIRE_TIME)
GO

CREATE NONCLUSTERED INDEX IDX_QRTZ_T_NFT_ST ON QRTZ_TRIGGERS(SCHED_NAME, TRIGGER_STATE, NEXT_FIRE_TIME)
GO

CREATE NONCLUSTERED INDEX IDX_QRTZ_T_NFT_ST_MISFIRE ON QRTZ_TRIGGERS(SCHED_NAME, MISFIRE_INSTR, NEXT_FIRE_TIME, TRIGGER_STATE)
GO

CREATE NONCLUSTERED INDEX IDX_QRTZ_T_NFT_ST_MISFIRE_GRP ON QRTZ_TRIGGERS(SCHED_NAME, MISFIRE_INSTR, NEXT_FIRE_TIME, TRIGGER_GROUP, TRIGGER_STATE)
GO

CREATE NONCLUSTERED INDEX IDX_QRTZ_T_STATE ON QRTZ_TRIGGERS(SCHED_NAME, TRIGGER_STATE)
GO

CREATE TABLE QRTZ_BLOB_TRIGGERS (SCHED_NAME varchar(120) NOT NULL, TRIGGER_NAME varchar(200) NOT NULL, TRIGGER_GROUP varchar(200) NOT NULL, BLOB_DATA varbinary(MAX))
GO

ALTER TABLE QRTZ_BLOB_TRIGGERS ADD PRIMARY KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP)
GO

CREATE TABLE QRTZ_SIMPROP_TRIGGERS (SCHED_NAME varchar(120) NOT NULL, TRIGGER_NAME varchar(200) NOT NULL, TRIGGER_GROUP varchar(200) NOT NULL, STR_PROP_1 varchar(512), STR_PROP_2 varchar(512), STR_PROP_3 varchar(512), INT_PROP_1 int, INT_PROP_2 int, LONG_PROP_1 bigint, LONG_PROP_2 bigint, DEC_PROP_1 numeric(13, 4), DEC_PROP_2 numeric(13, 4), BOOL_PROP_1 bit, BOOL_PROP_2 bit)
GO

ALTER TABLE QRTZ_SIMPROP_TRIGGERS ADD PRIMARY KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP)
GO

CREATE TABLE QRTZ_CRON_TRIGGERS (SCHED_NAME varchar(120) NOT NULL, TRIGGER_NAME varchar(200) NOT NULL, TRIGGER_GROUP varchar(200) NOT NULL, CRON_EXPRESSION varchar(120) NOT NULL, TIME_ZONE_ID varchar(80))
GO

ALTER TABLE QRTZ_CRON_TRIGGERS ADD PRIMARY KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP)
GO

CREATE TABLE QRTZ_SIMPLE_TRIGGERS (SCHED_NAME varchar(120) NOT NULL, TRIGGER_NAME varchar(200) NOT NULL, TRIGGER_GROUP varchar(200) NOT NULL, REPEAT_COUNT bigint NOT NULL, REPEAT_INTERVAL bigint NOT NULL, TIMES_TRIGGERED bigint NOT NULL)
GO

ALTER TABLE QRTZ_SIMPLE_TRIGGERS ADD PRIMARY KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP)
GO

ALTER TABLE QRTZ_TRIGGERS ADD CONSTRAINT QRTZ_TRIGGERS_FK FOREIGN KEY (SCHED_NAME, JOB_NAME, JOB_GROUP) REFERENCES QRTZ_JOB_DETAILS (SCHED_NAME, JOB_NAME, JOB_GROUP)
GO

ALTER TABLE QRTZ_SIMPLE_TRIGGERS ADD CONSTRAINT QRTZ_SIMPLE_TRIGGERS_FK FOREIGN KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) REFERENCES QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP)
GO

ALTER TABLE QRTZ_CRON_TRIGGERS ADD CONSTRAINT QRTZ_CRON_TRIGGERS_FK FOREIGN KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) REFERENCES QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP)
GO

ALTER TABLE QRTZ_SIMPROP_TRIGGERS ADD CONSTRAINT QRTZ_SIMPROP_TRIGGERS_FK FOREIGN KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) REFERENCES QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP)
GO

ALTER TABLE QRTZ_BLOB_TRIGGERS ADD CONSTRAINT QRTZ_BLOB_TRIGGERS_FK FOREIGN KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) REFERENCES QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('quartz-init', 'quartz', 'nschema/liquibase.quartz.init.xml', GETDATE(), 822, '8:a2fc1f56380aaa7ff4a1ac97105c7fb8', 'createTable tableName=QRTZ_LOCKS; addPrimaryKey tableName=QRTZ_LOCKS; createTable tableName=QRTZ_FIRED_TRIGGERS; addPrimaryKey tableName=QRTZ_FIRED_TRIGGERS; createIndex indexName=IDX_QRTZ_FT_INST_JOB_REQ_RCVRY, tableName=QRTZ_FIRED_TRIGGERS; crea...', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2207.changeLog.xml::20220228-em-1::emmar.masagca
UPDATE ekpversion SET dblevel = 2207, splevel = 0
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20220228-em-1', 'emmar.masagca', 'nschema/2207.changeLog.xml', GETDATE(), 823, '8:5b9cb885e6b67b28e68c99bc717cc734', 'update tableName=ekpversion', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2207.changeLog.xml::20220318-en-1::eddie.ng
-- PL-3097 Create Job Profile Assignment Type table
CREATE TABLE job_profile_assignment_type (id nvarchar(15) NOT NULL, code nvarchar(255) NOT NULL, display_name nvarchar(255), CONSTRAINT PK_JP_ASSIGNMENT_TYPE PRIMARY KEY (id))
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'job_profile_assignment_type'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.job_profile_assignment_type'; DECLARE @ColumnName SYSNAME set @ColumnName = N'id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Assignment Type ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'job_profile_assignment_type'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.job_profile_assignment_type'; DECLARE @ColumnName SYSNAME set @ColumnName = N'code'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Assignment Type Code';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'job_profile_assignment_type'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.job_profile_assignment_type'; DECLARE @ColumnName SYSNAME set @ColumnName = N'display_name'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Assignment Type Display Name';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20220318-en-1', 'eddie.ng', 'nschema/2207.changeLog.xml', GETDATE(), 824, '8:12459127b906dd15132daa136c8f291e', 'createTable tableName=job_profile_assignment_type', 'PL-3097 Create Job Profile Assignment Type table', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2207.changeLog.xml::20220318-en-2::eddie.ng
-- PL-3097 Add Assignment Type ID column to table user_job_profile
ALTER TABLE user_job_profile ADD assignment_type_id nvarchar(15)
GO

ALTER TABLE user_job_profile ADD CONSTRAINT FK_JP_ASSIGNMENT_TYPE_ID FOREIGN KEY (assignment_type_id) REFERENCES job_profile_assignment_type (id)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_job_profile'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_job_profile'; DECLARE @ColumnName SYSNAME set @ColumnName = N'assignment_type_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Assignment Type ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20220318-en-2', 'eddie.ng', 'nschema/2207.changeLog.xml', GETDATE(), 825, '8:54354ac1a8ae4d860a7d4e7dc8f5d15f', 'addColumn tableName=user_job_profile', 'PL-3097 Add Assignment Type ID column to table user_job_profile', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2207.changeLog.xml::20220401-em-1::emmar.masagca
ALTER TABLE job_profile_assignment_type ADD CONSTRAINT UK_JP_ASSIGNMENT_TYPE_CODE UNIQUE (code)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20220401-em-1', 'emmar.masagca', 'nschema/2207.changeLog.xml', GETDATE(), 826, '8:9c03bf6f868733217a6e97d7b2815f00', 'addUniqueConstraint constraintName=UK_JP_ASSIGNMENT_TYPE_CODE, tableName=job_profile_assignment_type', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2207.changeLog.xml::20220516-en-1::eddie.ng
-- PL-2734 Job Profile image
ALTER TABLE job_profile ADD picture nvarchar(255)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'job_profile'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.job_profile'; DECLARE @ColumnName SYSNAME set @ColumnName = N'picture'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Picture';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20220516-en-1', 'eddie.ng', 'nschema/2207.changeLog.xml', GETDATE(), 827, '8:d4c58e15d90ff0fb642164331a887c04', 'addColumn tableName=job_profile', 'PL-2734 Job Profile image', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2207.changeLog.xml::20220525-sc-1::shu.cui
-- NSD-6168 add check for n_completions_required > 0
UPDATE individual_competency SET n_completions_required = 1 WHERE n_completions_required=0
GO

DECLARE @sql [nvarchar](MAX)
SELECT @sql = N'ALTER TABLE individual_competency DROP CONSTRAINT ' + QUOTENAME([df].[name]) FROM [sys].[columns] AS [c] INNER JOIN [sys].[default_constraints] AS [df] ON [df].[object_id] = [c].[default_object_id] WHERE [c].[object_id] = OBJECT_ID(N'individual_competency') AND [c].[name] = N'n_completions_required'
EXEC sp_executesql @sql
GO

ALTER TABLE individual_competency ADD CONSTRAINT DF_individual_competency_n_completions_required DEFAULT 1 FOR n_completions_required
GO

ALTER TABLE individual_competency ADD CHECK (n_completions_required > 0)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20220525-sc-1', 'shu.cui', 'nschema/2207.changeLog.xml', GETDATE(), 828, '8:dc42810dfc068db33b56fc40c424cc7e', 'update tableName=individual_competency; dropDefaultValue columnName=n_completions_required, tableName=individual_competency; addDefaultValue columnName=n_completions_required, tableName=individual_competency; sql', 'NSD-6168 add check for n_completions_required > 0', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2211.changeLog.xml::20220623-ps-1::paul.strugnell
UPDATE ekpversion SET dblevel = 2211, splevel = 0
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20220623-ps-1', 'paul.strugnell', 'nschema/2211.changeLog.xml', GETDATE(), 829, '8:e6ceeceebd8ead1bd34e6b95d24b7557', 'update tableName=ekpversion', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2211.changeLog.xml::20220725-yf-1::yueqin.feng
-- PL-3819: New email notification - Exam Passed
ALTER TABLE mastertest ADD pass_email_id nvarchar(15)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'mastertest'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.mastertest'; DECLARE @ColumnName SYSNAME set @ColumnName = N'pass_email_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'The ID of the email template that will be sent to the user if the user passes this test.';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20220725-yf-1', 'yueqin.feng', 'nschema/2211.changeLog.xml', GETDATE(), 830, '8:cc406d929ec46be832345f8f0bad9fa0', 'addColumn tableName=mastertest', 'PL-3819: New email notification - Exam Passed', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2211.changeLog.xml::22020726-jw-1::Justin.wang
-- PLC-3: Update Job Profile Editor - Job Profile Dates(start and end ) for assign Job Profile in DB
ALTER TABLE job_profile ADD allows_assignment_start_date datetime
GO

ALTER TABLE job_profile ADD allows_assignment_end_date datetime
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'job_profile'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.job_profile'; DECLARE @ColumnName SYSNAME set @ColumnName = N'allows_assignment_start_date'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'This is the date a Job Profile after which will be available for users to self-assign or reviewer-assign, as well as for the system to automatically assign';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'job_profile'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.job_profile'; DECLARE @ColumnName SYSNAME set @ColumnName = N'allows_assignment_end_date'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'After this date the Job Profile will no longer be available for users to self-assign or reviewer-assign, as well as no longer automatically assign';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('22020726-jw-1', 'Justin.wang', 'nschema/2211.changeLog.xml', GETDATE(), 831, '8:64ed897d8655fffecb3d7cfaa0ca4133', 'addColumn tableName=job_profile', 'PLC-3: Update Job Profile Editor - Job Profile Dates(start and end ) for assign Job Profile in DB', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2211.changeLog.xml::20220802-yf-1::yueqin.feng
-- PL-3820: New email notification - Exam Ready to be Graded
ALTER TABLE mastertest ADD grade_notif_email_id nvarchar(15)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'mastertest'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.mastertest'; DECLARE @ColumnName SYSNAME set @ColumnName = N'grade_notif_email_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'The ID of the email template that will be sent to the user if the test instance is ready to be graded.';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20220802-yf-1', 'yueqin.feng', 'nschema/2211.changeLog.xml', GETDATE(), 832, '8:14ad318d91b9424d95512308c2154c0d', 'addColumn tableName=mastertest', 'PL-3820: New email notification - Exam Ready to be Graded', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2211.changeLog.xml::20220805-yf-1::yueqin.feng
-- PL-3608: Designate an Assignment Type via the Job Profile Auto-Assign screen
ALTER TABLE jobprofile_autoenroll ADD assignment_type_id nvarchar(15)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'jobprofile_autoenroll'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.jobprofile_autoenroll'; DECLARE @ColumnName SYSNAME set @ColumnName = N'assignment_type_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Job Profile Assignment Type ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20220805-yf-1', 'yueqin.feng', 'nschema/2211.changeLog.xml', GETDATE(), 833, '8:0be97f433b302be204d4a9bb91d94f55', 'addColumn tableName=jobprofile_autoenroll', 'PL-3608: Designate an Assignment Type via the Job Profile Auto-Assign screen', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2211.changeLog.xml::20220815-rl-1::richard.li
-- PLC-40 Add Quota column to Job Profile Competency table
ALTER TABLE job_profile_competency ADD competency_quota smallint
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'job_profile_competency'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.job_profile_competency'; DECLARE @ColumnName SYSNAME set @ColumnName = N'competency_quota'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Competency Quota';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20220815-rl-1', 'richard.li', 'nschema/2211.changeLog.xml', GETDATE(), 834, '8:b18a0bafa51ecf2a6492b065f86b2da7', 'addColumn tableName=job_profile_competency', 'PLC-40 Add Quota column to Job Profile Competency table', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2211.changeLog.xml::20220902-rl-1::richard.li
-- PLC-21 Create Job Profile - Job Profile Groups view
CREATE VIEW job_profile_group_vw AS SELECT
            jpg.id AS job_profile_group_id,
            jpg.name,
            jpg.poolid,
            jpg.description,
            jpg.is_active,
            jpg.reference_code,
            jpg.categoryid,
            jpg.certid,
            jpgm.job_profile_id
            FROM job_profile_group jpg
            INNER JOIN job_profile_group_map jpgm ON jpg.id = jpgm.job_profile_group_id
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20220902-rl-1', 'richard.li', 'nschema/2211.changeLog.xml', GETDATE(), 835, '8:ab0e24e73f2d241c636e9c10cd532ea2', 'createView viewName=job_profile_group_vw', 'PLC-21 Create Job Profile - Job Profile Groups view', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2211.changeLog.xml::20220924-vl-1::vincy.liu
-- PLC-30 Add Competency Quota and Job Profile Groups code and name in R116
DROP VIEW user_job_profile_competency_vw
GO

CREATE VIEW user_job_profile_competency_vw AS SELECT
            ujp.user_id,
            jp.id AS job_profile_id,
            jp.name AS job_profile_name,
            c.name,
            rl.level_order,
            jpcrl.level_order AS target_level_order,
            uc.assessment_mode,
            uc.assigned_by,
            uc.assigned_comment,
            jpc.competency_id,
            jpc.competency_quota,
            uc.competency_level_id,
            uc.date_assigned,
            rl.level_order - jpcrl.level_order AS gap,
            CASE
            WHEN rl.level_order IS NULL THEN 'N'
            WHEN jpcrl.level_order > rl.level_order THEN 'N'
            ELSE 'Y'
            END AS met,
            rl.code AS level_code,
            jpcrl.code AS target_level_code,
            jpc.competency_order,
            c.acquire_method,
            c.requires_all,
            c.n_completions_required,
            c.reference_code,
            c.description
            FROM user_job_profile ujp
            LEFT OUTER JOIN job_profile_competency jpc
            ON ujp.job_profile_id = jpc.job_profile_id
            LEFT OUTER JOIN user_competency uc
            ON jpc.competency_id = uc.competency_id AND ujp.user_id = uc.user_id
            LEFT OUTER JOIN competency_level cl
            ON cl.id = uc.competency_level_id
            LEFT OUTER JOIN tms_responsibility_level rl
            ON cl.res_id = rl.id
            LEFT OUTER JOIN competency_level jpcl
            ON jpcl.id = jpc.competency_target_level_id
            LEFT OUTER JOIN tms_responsibility_level jpcrl
            ON jpcrl.id = jpcl.res_id,
            individual_competency c, job_profile jp
            WHERE jp.id = ujp.job_profile_id
            AND jpc.job_profile_id = ujp.job_profile_id
            AND jpc.competency_id = c.id
            AND c.id = jpc.competency_id
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20220924-vl-1', 'vincy.liu', 'nschema/2211.changeLog.xml', GETDATE(), 836, '8:fac383500d01f6368ab053227d6dea11', 'dropView viewName=user_job_profile_competency_vw; createView viewName=user_job_profile_competency_vw', 'PLC-30 Add Competency Quota and Job Profile Groups code and name in R116', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2211.changeLog.xml::20221018-en-1::eddie.ng
-- PL-3811 Add included columns to index in resource_string
DROP INDEX nuk_res_string_bundle_id ON resource_string
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20221018-en-1', 'eddie.ng', 'nschema/2211.changeLog.xml', GETDATE(), 837, '8:a4aca7ef3cee6d28119f5b355b780097', 'dropIndex indexName=nuk_res_string_bundle_id, tableName=resource_string', 'PL-3811 Add included columns to index in resource_string', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2211.changeLog.xml::20221018-en-2::eddie.ng
-- PL-3811 Add included columns to index in resource_string
CREATE NONCLUSTERED INDEX nuk_res_string_bundle_id
            ON resource_string (bundle_id)
            INCLUDE (id, value_varchar, value_ntext, reference_id, field)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20221018-en-2', 'eddie.ng', 'nschema/2211.changeLog.xml', GETDATE(), 838, '8:81298f4a1bfd1e4c9429ac7ba9faf880', 'sql', 'PL-3811 Add included columns to index in resource_string', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2303.changeLog.xml::20221103-sc-1::shu.cui
UPDATE ekpversion SET dblevel = 2303, splevel = 0
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20221103-sc-1', 'shu.cui', 'nschema/2303.changeLog.xml', GETDATE(), 839, '8:31069739df2d7447191758e40836b705', 'update tableName=ekpversion', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2303.changeLog.xml::20221117-mg-1::michael.gorohov
-- PL-1869 unutilized indexes came as part of index analysis report from dba
DROP INDEX NUK_CERT_SCHEDULE_DATE ON cert_schedule
GO

DROP INDEX NUK_COMP_AP_Q_OWNER ON comp_approval_queue
GO

DROP INDEX NUK_CO_LOID ON ContentOrganization
GO

DROP INDEX nuk_eval_event ON evaluation
GO

DROP INDEX NUK_PAYMENT_X1 ON payment
GO

DROP INDEX NUK_PAYMENT_X2 ON payment
GO

DROP INDEX NUK_PERMISSION_TEMPLATE_HASH ON permission_template
GO

DROP INDEX NUK_TRAN_HIST_LID_SID ON transcript_history
GO

DROP INDEX NUK_TRANS_STATLOG_LOGDATE ON transcript_stat_log
GO

DROP INDEX NUK_GTT_ORGANIZER ON vc_gtt_organizer
GO

DROP INDEX IF EXISTS [NUK_OTHER_LTYPE] ON [dbo].[otherObjects]
GO

DROP INDEX IF EXISTS [NUK_USERS_L123] ON [dbo].[users_assignment]
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20221117-mg-1', 'michael.gorohov', 'nschema/2303.changeLog.xml', GETDATE(), 840, '8:89f5205e1ec019328d7136830dbd6946', 'dropIndex indexName=NUK_CERT_SCHEDULE_DATE, tableName=cert_schedule; dropIndex indexName=NUK_COMP_AP_Q_OWNER, tableName=comp_approval_queue; dropIndex indexName=NUK_CO_LOID, tableName=ContentOrganization; dropIndex indexName=nuk_eval_event, tableN...', 'PL-1869 unutilized indexes came as part of index analysis report from dba', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2303.changeLog.xml::20221130-sk-1::sachin.kumar
-- PL-4425 Allow the currentPID to be 255 characters in length
ALTER TABLE users_meta ALTER COLUMN currentPID nvarchar(255)
GO

ALTER TABLE users_assignment ALTER COLUMN assignment_ref_code nvarchar(425)
GO

ALTER TABLE user_merge_history ALTER COLUMN actor_currentpid nvarchar(255)
GO

ALTER TABLE user_merge_history ALTER COLUMN source_currentpid nvarchar(255)
GO

ALTER TABLE user_merge_history ALTER COLUMN target_currentpid nvarchar(255)
GO

ALTER TABLE stats_overall ALTER COLUMN creator_pid nvarchar(255)
GO

ALTER TABLE auditobjects ALTER COLUMN objectid nvarchar(255)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20221130-sk-1', 'sachin.kumar', 'nschema/2303.changeLog.xml', GETDATE(), 841, '8:5070952afbe0787e53ea6ea34536de8c', 'modifyDataType columnName=currentPID, tableName=users_meta; modifyDataType columnName=assignment_ref_code, tableName=users_assignment; modifyDataType columnName=actor_currentpid, tableName=user_merge_history; modifyDataType columnName=source_curre...', 'PL-4425 Allow the currentPID to be 255 characters in length', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2307.changeLog.xml::20230220-yf-1::yueqin.feng
UPDATE ekpversion SET dblevel = 2307, splevel = 0
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20230220-yf-1', 'yueqin.feng', 'nschema/2307.changeLog.xml', GETDATE(), 842, '8:ac7a25a536fb61a2d4e6e42ce5a2878f', 'update tableName=ekpversion', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2307.changeLog.xml::20230307-sc-1::shu.cui
-- PL-5077 Create table to store scheduled task history
CREATE TABLE scheduled_task_log (task_name nvarchar(85) NOT NULL, status char(1) NOT NULL, message nvarchar (max), start_time datetime NOT NULL, end_time datetime)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'scheduled_task_log'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.scheduled_task_log'; DECLARE @ColumnName SYSNAME set @ColumnName = N'task_name'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Scheduled Task Name';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'scheduled_task_log'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.scheduled_task_log'; DECLARE @ColumnName SYSNAME set @ColumnName = N'status'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Job Status';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'scheduled_task_log'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.scheduled_task_log'; DECLARE @ColumnName SYSNAME set @ColumnName = N'message'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Log Message';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'scheduled_task_log'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.scheduled_task_log'; DECLARE @ColumnName SYSNAME set @ColumnName = N'start_time'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Task Start Time';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'scheduled_task_log'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.scheduled_task_log'; DECLARE @ColumnName SYSNAME set @ColumnName = N'end_time'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Task End Time';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20230307-sc-1', 'shu.cui', 'nschema/2307.changeLog.xml', GETDATE(), 843, '8:e9cd9692154dde41f8f53f518fc560a8', 'createTable tableName=scheduled_task_log', 'PL-5077 Create table to store scheduled task history', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2307.changeLog.xml::20230317-ct-1::craig.taylor
-- PL-5103 for PL-4923 User MFA
CREATE TABLE user_mfa (userid nvarchar(85) NOT NULL, mfaBypass char(1) CONSTRAINT DF_user_mfa_mfaBypass DEFAULT 'N' NOT NULL, onetimepass nvarchar(255), onetimeexpiration datetime)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_mfa'; DECLARE @FullTableName SYSNAME; SET @FullTableName = @DynamicSchemaName + N'.user_mfa';DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'User MFA configuration';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.name = N'MS_Description' AND ep.minor_id=0); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_mfa'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_mfa'; DECLARE @ColumnName SYSNAME set @ColumnName = N'userid'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'reference user id';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_mfa'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_mfa'; DECLARE @ColumnName SYSNAME set @ColumnName = N'mfaBypass'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'mfaBypass enum Y-bypass_enabled, N-bypass_disabled';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_mfa'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_mfa'; DECLARE @ColumnName SYSNAME set @ColumnName = N'onetimepass'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'one time password';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_mfa'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_mfa'; DECLARE @ColumnName SYSNAME set @ColumnName = N'onetimeexpiration'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'expiration date for one time password';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20230317-ct-1', 'craig.taylor', 'nschema/2307.changeLog.xml', GETDATE(), 844, '8:f7729beb69a553a0b4aa7353945999dd', 'createTable tableName=user_mfa', 'PL-5103 for PL-4923 User MFA', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2307.changeLog.xml::20230413-rb-1::Ryan.Buchanan
ALTER TABLE user_mfa ADD lastSuccessfulLogin datetime
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_mfa'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_mfa'; DECLARE @ColumnName SYSNAME set @ColumnName = N'lastSuccessfulLogin'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'date of last successful login attempt';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20230413-rb-1', 'Ryan.Buchanan', 'nschema/2307.changeLog.xml', GETDATE(), 845, '8:7be5c74a1105d4b2d24a46c59a503ac4', 'addColumn tableName=user_mfa', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2307.changeLog.xml::20230419-sc-1::shu.cui
-- PL-5159 change organization code length
ALTER TABLE code_orgstructure ALTER COLUMN orgcode nvarchar(255)
GO

ALTER TABLE code_orgstructure ALTER COLUMN description nvarchar(255)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20230419-sc-1', 'shu.cui', 'nschema/2307.changeLog.xml', GETDATE(), 846, '8:d4f40a9a9f3a081875c15ddd5c4eeca8', 'modifyDataType columnName=orgcode, tableName=code_orgstructure; modifyDataType columnName=description, tableName=code_orgstructure', 'PL-5159 change organization code length', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2307.changeLog.xml::20230427-rl-1::richard.li
-- PLC-135 Create Encrypt, Report Location and SFTP Transfer in the Schedule Report Properties screen
ALTER TABLE schedule_report ADD encrypt char(1) CONSTRAINT DF_schedule_report_encrypt DEFAULT 'N' NOT NULL
GO

ALTER TABLE schedule_report ADD report_location nvarchar(255)
GO

ALTER TABLE schedule_report ADD sftp_transfer_id nvarchar(15)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'schedule_report'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.schedule_report'; DECLARE @ColumnName SYSNAME set @ColumnName = N'encrypt'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Whether need encrypt the report';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'schedule_report'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.schedule_report'; DECLARE @ColumnName SYSNAME set @ColumnName = N'report_location'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Report location';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'schedule_report'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.schedule_report'; DECLARE @ColumnName SYSNAME set @ColumnName = N'sftp_transfer_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'The ID of the SFTP Transfer';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20230427-rl-1', 'richard.li', 'nschema/2307.changeLog.xml', GETDATE(), 847, '8:ada9338d7b439689de2edda304de23da', 'addColumn tableName=schedule_report', 'PLC-135 Create Encrypt, Report Location and SFTP Transfer in the Schedule Report Properties screen', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2307.changeLog.xml::20230503-mg-1::michael.gorohov
ALTER TABLE transcript ADD percent_completion int
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'transcript'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.transcript'; DECLARE @ColumnName SYSNAME set @ColumnName = N'percent_completion'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Percentage of Completion';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20230503-mg-1', 'michael.gorohov', 'nschema/2307.changeLog.xml', GETDATE(), 848, '8:041565ab7ae1b18538e0cce874aa8794', 'addColumn tableName=transcript', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2307.changeLog.xml::20230503-mg-3::michael.gorohov
DROP VIEW aggregated_transcript_vw
GO

CREATE VIEW aggregated_transcript_vw AS SELECT
            t1.transcriptid,
            a2.userid,
            t1.learningid,
            t1.currid,
            t1.learningType,
            t1.eventid,
            t1.startdate,
            t1.finishdate,
            t1.finalgrade,
            t1.studentstatus,
            tsub.substatus_code,
            tsub.substatus_name,
            t1.progress,
            t1.assessDate,
            t1.attendance,
            t1.perfGradeid,
            t1.sessionid,
            t1.creditTranscriptLink,
            t1.curriculumTranscriptLink,
            t1.assessmentscore,
            t1.requestSource,
            t1.contentSessionID,
            t1.certSessionID,
            t1.enrollmentDate,
            t1.remindercount,
            t1.costcenter,
            t1.confirmation_status,
            t1.reopen,
            t1.isOpen,
            t1.pre_assess_score,
            t1.post_assess_score,
            t1.settings_as_of_date,
            t1.quick_eval,
            t1.notifyemail,
            t1.completion_deadline,
            t1.deadline_expired,
            t1.revision_number,
            t1.ntraininghours,
            t1.allowDappraiserAssess,
            t1.offline_key,
            t1.mekp_sync,
            t1.send_notif_ew,
            t1.update_meaning,
            t1.last_updated,
            t1.updater_legal_name,
            t1.update_meaning_text,
            t1.last_updater_uid,
            t1.creator_uid,
            t1.datecreated,
            t1.curr_total_time,
            t1.attempts_allowed,
            t1.grading_method,
            t1.attempts_count,
            t1.completion_method,
            t1.final_score,
            t1.weighting,
            t1.weightedscore,
            t1.percent_completion,
            case when EXISTS(SELECT * FROM submod_tran_subt WHERE program_tran_id = t1.transcriptid) then 'Y'
            else 'N' end as sub_learning,
            case when a2.userid = t1.userid then 'Y' else 'N' end belongsToLearnerAssignment,
            t1.is_reqd_custom_attr_complete,
            t1.bundle_id,
            t1.allowBundleSwitch,
            case when lang.ilangid is null then lang.locale else cast(lang.ilangid as char) end language_tag,
            t1.transcriptid as resolved_transcriptid
            FROM transcript t1
            inner join users_assignment a1 on a1.userid = t1.userid
            inner join users_assignment a2 on a2.user_meta_id = a1.user_meta_id
            left join transcript_substatus tsub on t1.student_substatus = tsub.id
            inner join language_bundle lang on lang.bundle_id = t1.bundle_id
            WHERE t1.studentstatus NOT IN (8, 9, 10)
            UNION ALL
            SELECT
            a.transcriptid,
            a2.userid,
            a.learningid,
            a.currid,
            a.learningType,
            a.eventid,
            b.startdate,
            b.finishdate,
            b.finalgrade,
            b.studentstatus,
            tsub.substatus_code,
            tsub.substatus_name,
            b.progress,
            b.assessDate,
            b.attendance,
            b.perfGradeid,
            a.sessionid,
            CASE WHEN 1=1 THEN NULL ELSE '' END as creditTranscriptLink,
            a.curriculumTranscriptLink,
            b.assessmentscore,
            a.requestSource,
            b.contentSessionID,
            b.certSessionID,
            a.enrollmentDate,
            b.remindercount,
            b.costcenter,
            b.confirmation_status,
            b.reopen,
            a.isOpen,
            b.pre_assess_score,
            b.post_assess_score,
            b.settings_as_of_date,
            b.quick_eval,
            b.notifyemail,
            b.completion_deadline,
            b.deadline_expired,
            b.revision_number,
            b.ntraininghours,
            b.allowDappraiserAssess,
            b.offline_key,
            b.mekp_sync,
            b.send_notif_ew,
            b.update_meaning,
            b.last_updated,
            b.updater_legal_name,
            a.update_meaning_text,
            a.last_updater_uid,
            a.creator_uid,
            a.datecreated,
            b.curr_total_time,
            b.attempts_allowed,
            b.grading_method,
            b.attempts_count,
            b.completion_method,
            b.final_score,
            b.weighting,
            b.weightedscore,
            b.percent_completion,
            case when EXISTS(SELECT * FROM submod_tran_subt WHERE program_tran_id = b.transcriptid) then 'Y'
            else 'N' end as sub_learning,
            case when a2.userid = a.userid then 'Y' else 'N' end belongsToLearnerAssignment,
            b.is_reqd_custom_attr_complete,
            b.bundle_id,
            b.allowBundleSwitch,
            case when lang.ilangid is null then lang.locale else cast(lang.ilangid as char) end language_tag,
            a.creditTranscriptLink as resolved_transcriptid
            FROM transcript a
            inner join transcript b on b.transcriptid = a.creditTranscriptLink
            inner join users_assignment a1 on a1.userid = a.userid
            inner join users_assignment a2 on a2.user_meta_id = a1.user_meta_id
            left join transcript_substatus tsub on a.student_substatus = tsub.id
            inner join language_bundle lang on b.bundle_id = lang.bundle_id
            WHERE a.studentstatus = 8 AND b.transcriptid = a.creditTranscriptLink AND b.studentstatus NOT IN (8, 9, 10)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20230503-mg-3', 'michael.gorohov', 'nschema/2307.changeLog.xml', GETDATE(), 849, '8:68b1a12e4695530fa8e21d74b861d117', 'dropView viewName=aggregated_transcript_vw; createView viewName=aggregated_transcript_vw', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2307.changeLog.xml::20230505-jw-1::Justin.wang
-- SFTP Location  in DB
CREATE TABLE sftp_location (id nvarchar(15) NOT NULL, display_name nvarchar(255) NOT NULL, created_by nvarchar(85), created_date datetime, last_update_by nvarchar(85), last_updated datetime, url nvarchar(255) NOT NULL, port numeric(5, 0) NOT NULL, loginName nvarchar(255) NOT NULL, password nvarchar(255), sshKey nvarchar(4000), isByPassword char(1) CONSTRAINT DF_sftp_location_isByPassword DEFAULT 'Y' NOT NULL, CONSTRAINT PK_SFTP_LOCATION PRIMARY KEY (id))
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'sftp_location'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.sftp_location'; DECLARE @ColumnName SYSNAME set @ColumnName = N'id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'SFTP Location ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'sftp_location'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.sftp_location'; DECLARE @ColumnName SYSNAME set @ColumnName = N'display_name'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'SFTP Location display name';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'sftp_location'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.sftp_location'; DECLARE @ColumnName SYSNAME set @ColumnName = N'created_by'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'created By';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'sftp_location'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.sftp_location'; DECLARE @ColumnName SYSNAME set @ColumnName = N'created_date'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'created date';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'sftp_location'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.sftp_location'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_update_by'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'last update by';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'sftp_location'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.sftp_location'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_updated'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'last updated';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'sftp_location'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.sftp_location'; DECLARE @ColumnName SYSNAME set @ColumnName = N'url'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'SFTP Location url';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'sftp_location'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.sftp_location'; DECLARE @ColumnName SYSNAME set @ColumnName = N'port'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'SFTP Location port';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'sftp_location'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.sftp_location'; DECLARE @ColumnName SYSNAME set @ColumnName = N'loginName'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'SFTP Location loginName';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'sftp_location'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.sftp_location'; DECLARE @ColumnName SYSNAME set @ColumnName = N'password'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'SFTP Location password';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'sftp_location'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.sftp_location'; DECLARE @ColumnName SYSNAME set @ColumnName = N'sshKey'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'SFTP Location sshKey';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20230505-jw-1', 'Justin.wang', 'nschema/2307.changeLog.xml', GETDATE(), 850, '8:ff176493b433a227e99867214f0a0828', 'createTable tableName=sftp_location', 'SFTP Location  in DB', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2307.changeLog.xml::20230525-ct-1::craig.taylor
-- Additional options for exams
ALTER TABLE mastertest ADD rcd_post_compl_attempt char(1) CONSTRAINT DF_mastertest_rcd_post_compl_attempt DEFAULT 'N' NOT NULL
GO

ALTER TABLE mastertest ADD rcd_post_compl_max_score char(1) CONSTRAINT DF_mastertest_rcd_post_compl_max_score DEFAULT 'N' NOT NULL
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20230525-ct-1', 'craig.taylor', 'nschema/2307.changeLog.xml', GETDATE(), 851, '8:dfbb9c7cf8bf067d5d635c641443b43b', 'addColumn tableName=mastertest', 'Additional options for exams', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2307.changeLog.xml::20230525-ct-2::craig.taylor
-- Keep MFA number of attempts
ALTER TABLE user_mfa ADD nAttempts int CONSTRAINT DF_user_mfa_nAttempts DEFAULT 0 NOT NULL
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20230525-ct-2', 'craig.taylor', 'nschema/2307.changeLog.xml', GETDATE(), 852, '8:ceab46d17dd10d83391c5c273a552b1f', 'addColumn tableName=user_mfa', 'Keep MFA number of attempts', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2311.changeLog.xml::20230613-em-1::emmar.masagca
UPDATE ekpversion SET dblevel = 2311, splevel = 0
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20230613-em-1', 'emmar.masagca', 'nschema/2311.changeLog.xml', GETDATE(), 853, '8:816cf5563e42001d3ca135768035adf2', 'update tableName=ekpversion', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2311.changeLog.xml::20230630-mg-1::michael.gorohov
-- PL-5920 Database changes for post-exam information field and description column type update
ALTER TABLE mastertest ADD post_exam_info nvarchar (max)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'mastertest'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.mastertest'; DECLARE @ColumnName SYSNAME set @ColumnName = N'post_exam_info'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Post-Exam Information';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20230630-mg-1', 'michael.gorohov', 'nschema/2311.changeLog.xml', GETDATE(), 854, '8:8225d53f9dee11d1f2682068b6018705', 'addColumn tableName=mastertest', 'PL-5920 Database changes for post-exam information field and description column type update', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2311.changeLog.xml::20230711-jw-1::Justin.wang
-- Configuration for skipping questions at exam Level
ALTER TABLE mastertest ADD missing_answer char(1) CONSTRAINT DF_mastertest_missing_answer DEFAULT 'G' NOT NULL
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'mastertest'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.mastertest'; DECLARE @ColumnName SYSNAME set @ColumnName = N'missing_answer'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'G means to use the global system default setting,               F means force answer,all questions must be answered,               W means warning only,allow user to skip question(s)';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20230711-jw-1', 'Justin.wang', 'nschema/2311.changeLog.xml', GETDATE(), 855, '8:79923ee525eb81597566fb941abc72c7', 'addColumn tableName=mastertest', 'Configuration for skipping questions at exam Level', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2311.changeLog.xml::20230711-jw-2::Justin.wang
-- Allow unlimited printing of the exam
ALTER TABLE mastertest ADD allow_unlimited_print char(1) CONSTRAINT DF_mastertest_allow_unlimited_print DEFAULT 'N' NOT NULL
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20230711-jw-2', 'Justin.wang', 'nschema/2311.changeLog.xml', GETDATE(), 856, '8:08a25df9f3fc2af392d00cef8f7ab56a', 'addColumn tableName=mastertest', 'Allow unlimited printing of the exam', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2311.changeLog.xml::20230830-rb-1::ryan.buchanan
-- PL-6166 Database changes for Resit Calculation
ALTER TABLE mastertest ADD resitForOverallExam char(1) CONSTRAINT DF_mastertest_resitForOverallExam DEFAULT 'N' NOT NULL
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'mastertest'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.mastertest'; DECLARE @ColumnName SYSNAME set @ColumnName = N'resitForOverallExam'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Resit Calculation For Overall Exam';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20230830-rb-1', 'ryan.buchanan', 'nschema/2311.changeLog.xml', GETDATE(), 857, '8:0d7c66d19464f3cb6285bca145d22655', 'addColumn tableName=mastertest', 'PL-6166 Database changes for Resit Calculation', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2311.changeLog.xml::20230910-jw-1::Justin.wang
-- Allow Multiple Choice Partial Credit of the exam
ALTER TABLE mastertest ADD partial_credit char(1) CONSTRAINT DF_mastertest_partial_credit DEFAULT 'G' NOT NULL
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'mastertest'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.mastertest'; DECLARE @ColumnName SYSNAME set @ColumnName = N'partial_credit'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'G means to use the global system default setting,               A All or Nothing,               U Uniform Partial Credit';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20230910-jw-1', 'Justin.wang', 'nschema/2311.changeLog.xml', GETDATE(), 858, '8:0320ffdd748e9c0f7f95b93c628b8a28', 'addColumn tableName=mastertest', 'Allow Multiple Choice Partial Credit of the exam', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2311.changeLog.xml::20231003-mg-1::michael.gorohov
CREATE TABLE template_widget_recom_config (widget_id nvarchar(15) NOT NULL, title nvarchar(255), recommendation_setting nvarchar(15), CONSTRAINT PK_WIDGET_RECOM_CONFIG PRIMARY KEY (widget_id))
GO

ALTER TABLE template_widget_recom_config ADD CONSTRAINT FK_WIDGET_RECOM_CONFIG FOREIGN KEY (widget_id) REFERENCES template_widget (id) ON DELETE CASCADE
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20231003-mg-1', 'michael.gorohov', 'nschema/2311.changeLog.xml', GETDATE(), 859, '8:61902214514ad1205728435530df8c22', 'createTable tableName=template_widget_recom_config; addForeignKeyConstraint baseTableName=template_widget_recom_config, constraintName=FK_WIDGET_RECOM_CONFIG, referencedTableName=template_widget', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2401.changeLog.xml::20231110-rn-1::ronald.ng
UPDATE ekpversion SET dblevel = 2401, splevel = 0
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20231110-rn-1', 'ronald.ng', 'nschema/2401.changeLog.xml', GETDATE(), 860, '8:f72102ac306cea3777ca728e64e4a6de', 'update tableName=ekpversion', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2401.changeLog.xml::20231113-rli-1::richard.li
-- PLC-301-Changes to User Editor
ALTER TABLE userprefs_assignment ADD job_profile_group_type smallint CONSTRAINT DF_userprefs_assignment_job_profile_group_type DEFAULT 255 NOT NULL
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'userprefs_assignment'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.userprefs_assignment'; DECLARE @ColumnName SYSNAME set @ColumnName = N'job_profile_group_type'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Job Profile Group assignment type: 255-All; 254-Specific';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20231113-rli-1', 'richard.li', 'nschema/2401.changeLog.xml', GETDATE(), 861, '8:87c00b68a43fc05abcfe49e9324c6119', 'addColumn tableName=userprefs_assignment', 'PLC-301-Changes to User Editor', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2401.changeLog.xml::20231113-rli-2::richard.li
-- PLC-301-Changes to User Editor
CREATE TABLE user_job_profile_groups_map (userid nvarchar(85) NOT NULL, job_profile_group_id nvarchar(15) NOT NULL)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_job_profile_groups_map'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_job_profile_groups_map'; DECLARE @ColumnName SYSNAME set @ColumnName = N'userid'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'User ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'user_job_profile_groups_map'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.user_job_profile_groups_map'; DECLARE @ColumnName SYSNAME set @ColumnName = N'job_profile_group_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Job Profile Group ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

ALTER TABLE user_job_profile_groups_map ADD CONSTRAINT PK_USER_JOB_PROFILE_GROUPS_MAP PRIMARY KEY (userid, job_profile_group_id)
GO

ALTER TABLE user_job_profile_groups_map ADD CONSTRAINT FK_USER_JOB_PROFILE_GROUPS_MAP FOREIGN KEY (job_profile_group_id) REFERENCES job_profile_group (id)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20231113-rli-2', 'richard.li', 'nschema/2401.changeLog.xml', GETDATE(), 862, '8:00e69726e5d3ab5196a9c3a9b291c886', 'createTable tableName=user_job_profile_groups_map; addPrimaryKey constraintName=PK_USER_JOB_PROFILE_GROUPS_MAP, tableName=user_job_profile_groups_map; addForeignKeyConstraint baseTableName=user_job_profile_groups_map, constraintName=FK_USER_JOB_PR...', 'PLC-301-Changes to User Editor', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2401.changeLog.xml::20231113-rli-3::richard.li
-- PLC-301-Changes to User Editor
DROP VIEW userprefs
GO

CREATE VIEW userprefs AS select userprefs_assignment.userid,
            userprefs_assignment.contentServer,
            userprefs_assignment.ui,
            users_meta.languagepref,
            userprefs_assignment.autoMailList,
            userprefs_assignment.autoRegMsg,
            users_meta.useExternalMail,
            userprefs_assignment.initialURL,
            userprefs_assignment.resultsPerPage,
            userprefs_assignment.catalogid,
            userprefs_assignment.userPref1,
            userprefs_assignment.userPref2,
            userprefs_assignment.time_zone,
            users_meta.email_forward_type,
            users_meta.forward_to_email,
            userprefs_assignment.welcome_email_senddate,
            users_meta.block_notification,
            userprefs_assignment.enable_newui,
            userprefs_assignment.job_profile_group_type
            from userprefs_assignment
            JOIN users_assignment on userprefs_assignment.userid = users_assignment.userid
            JOIN users_meta on users_assignment.user_meta_id = users_meta.user_meta_id
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20231113-rli-3', 'richard.li', 'nschema/2401.changeLog.xml', GETDATE(), 863, '8:953e47cc314862442d7c25b35d29ad2b', 'dropView viewName=userprefs; createView viewName=userprefs', 'PLC-301-Changes to User Editor', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2404.changeLog.xml::20231017-rn-1::ronald.ng
UPDATE ekpversion SET dblevel = 2404, splevel = 0
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20231017-rn-1', 'ronald.ng', 'nschema/2404.changeLog.xml', GETDATE(), 864, '8:0864154247c316babb25d4fc92879d5c', 'update tableName=ekpversion', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2404.changeLog.xml::20231120-sc-1::shu.cui
-- NSD-9066 Update session enrollment count calculation logic
DROP VIEW cschedule_nreserved_vw
GO

CREATE VIEW cschedule_nreserved_vw AS SELECT c.courseid, c.eventid,
                   SUM(CASE WHEN t.studentstatus IS NULL THEN 0
                            WHEN m.consider_reserve_only='N' THEN 1
                            WHEN (m.consider_reserve_only='Y' AND t.reserve_seat ='Y' AND t.studentstatus = 7) THEN 1
                            WHEN (m.consider_reserve_only='Y' AND t.reserve_seat ='Y' AND t.studentstatus = 1 AND c.availability!='X') THEN 1
                            ELSE 0 END) nreserved
            FROM cschedule c
                     INNER JOIN code_enroll_cnt_method m ON m.method = c.enroll_cnt_method
                     LEFT JOIN transcript t ON t.eventid = c.eventid AND t.studentstatus = m.studentstatus
            GROUP BY c.courseid, c.eventid
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20231120-sc-1', 'shu.cui', 'nschema/2404.changeLog.xml', GETDATE(), 865, '8:2b0f4a58d50013ed473fc58875a24842', 'dropView viewName=cschedule_nreserved_vw; createView viewName=cschedule_nreserved_vw', 'NSD-9066 Update session enrollment count calculation logic', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2404.changeLog.xml::20240311-yf-1::yueqin.feng
-- PL-7239: Change the current PeopleFluent LMS Default skin to use the new colors and logo
UPDATE screenLayout SET primary_color = '#1F3055', secondary_color = '#2A4072' WHERE shortname='PeopleFluent_LMS_Default' AND directory='lms-skin'
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20240311-yf-1', 'yueqin.feng', 'nschema/2404.changeLog.xml', GETDATE(), 866, '8:469b44cba4ee3371ad0566b432590317', 'update tableName=screenLayout', 'PL-7239: Change the current PeopleFluent LMS Default skin to use the new colors and logo', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2404.changeLog.xml::20240228-jw-1::Justin.wang
-- PLC-340 Configuring the Courses
CREATE TABLE lti_tool_launcher (course_id nvarchar(85) NOT NULL, lti_tool_id nvarchar(85) NOT NULL, last_updater_uid nvarchar(85), last_updated datetime, updater_legal_name nvarchar(1000), update_meaning_text nvarchar (max), CONSTRAINT PK_LTI_TOOL_COURSE PRIMARY KEY (course_id))
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'lti_tool_launcher'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.lti_tool_launcher'; DECLARE @ColumnName SYSNAME set @ColumnName = N'course_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Primary key, Learning ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'lti_tool_launcher'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.lti_tool_launcher'; DECLARE @ColumnName SYSNAME set @ColumnName = N'lti_tool_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'LTI Tool ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'lti_tool_launcher'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.lti_tool_launcher'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_updater_uid'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'UID of change maker';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'lti_tool_launcher'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.lti_tool_launcher'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_updated'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'System datetime of the change';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'lti_tool_launcher'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.lti_tool_launcher'; DECLARE @ColumnName SYSNAME set @ColumnName = N'updater_legal_name'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Legal name of change maker';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'lti_tool_launcher'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.lti_tool_launcher'; DECLARE @ColumnName SYSNAME set @ColumnName = N'update_meaning_text'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Update remark';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20240228-jw-1', 'Justin.wang', 'nschema/2404.changeLog.xml', GETDATE(), 867, '8:f222d29a8ccdff92091c1d17ce46c1c3', 'createTable tableName=lti_tool_launcher', 'PLC-340 Configuring the Courses', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2404.changeLog.xml::20240228-jw-2::Justin.wang
-- PLC-338 TLI Tool in DB
CREATE TABLE lti_tool (id nvarchar(85) NOT NULL, lti_version nvarchar(255) NOT NULL, lti_code nvarchar(255) NOT NULL, lti_display_name nvarchar(255) NOT NULL, public_key nvarchar(4000) NOT NULL, init_url nvarchar(1024) NOT NULL, redirect_url nvarchar(1024) NOT NULL, is_send_anon char(1) CONSTRAINT DF_lti_tool_is_send_anon DEFAULT 'Y' NOT NULL, is_multiple_enroll char(1) CONSTRAINT DF_lti_tool_is_multiple_enroll DEFAULT 'Y' NOT NULL, issuer nvarchar(255), client_id nvarchar(255), deployment_id nvarchar(255), odic_url nvarchar(255), jwks_endpoint nvarchar(255), max_inactive_interval nvarchar(255), CONSTRAINT PK_LTI_Tool PRIMARY KEY (id))
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'lti_tool'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.lti_tool'; DECLARE @ColumnName SYSNAME set @ColumnName = N'id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'LTI Tool ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'lti_tool'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.lti_tool'; DECLARE @ColumnName SYSNAME set @ColumnName = N'lti_version'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'LTI Tool version';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'lti_tool'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.lti_tool'; DECLARE @ColumnName SYSNAME set @ColumnName = N'lti_code'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'LTI Tool code';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'lti_tool'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.lti_tool'; DECLARE @ColumnName SYSNAME set @ColumnName = N'lti_display_name'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'LTI Tool display name';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'lti_tool'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.lti_tool'; DECLARE @ColumnName SYSNAME set @ColumnName = N'public_key'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'The RSA 256 public key associated with the tool.';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'lti_tool'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.lti_tool'; DECLARE @ColumnName SYSNAME set @ColumnName = N'init_url'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'The endpoint the platform will use to initiate the OpenID Connect authorization flow';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'lti_tool'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.lti_tool'; DECLARE @ColumnName SYSNAME set @ColumnName = N'redirect_url'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'One or more URIs where the OIDC Authorization Response can be sent';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'lti_tool'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.lti_tool'; DECLARE @ColumnName SYSNAME set @ColumnName = N'issuer'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'The value of the required LtiPlatformIssuer configuration setting';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'lti_tool'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.lti_tool'; DECLARE @ColumnName SYSNAME set @ColumnName = N'client_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'The OAuth Client Id for the tool. JSON Web Tokens sent to the tool will have this value in the aud claim.';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'lti_tool'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.lti_tool'; DECLARE @ColumnName SYSNAME set @ColumnName = N'deployment_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'An identifier for the integration between the platform and the tool. Identical to the connectorId.';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'lti_tool'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.lti_tool'; DECLARE @ColumnName SYSNAME set @ColumnName = N'odic_url'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'The endpoint where the tool should send the OIDC Authorization Request.';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'lti_tool'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.lti_tool'; DECLARE @ColumnName SYSNAME set @ColumnName = N'jwks_endpoint'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'A link to access the platform''s JSON Web Key Set. This will be an absolute, unsecured URL to the /plugin/lti13/{connectorId}/jwks endpoint.';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20240228-jw-2', 'Justin.wang', 'nschema/2404.changeLog.xml', GETDATE(), 868, '8:e7b0054a8b56ad130626da102e529071', 'createTable tableName=lti_tool', 'PLC-338 TLI Tool in DB', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2409.changeLog.xml::20240415-sc-1::shu.cui
UPDATE ekpversion SET dblevel = 2409, splevel = 0
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20240415-sc-1', 'shu.cui', 'nschema/2409.changeLog.xml', GETDATE(), 869, '8:8c4aa1a83e7a6a74659dfba949d6814d', 'update tableName=ekpversion', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2409.changeLog.xml::20240229-rli-1::richard.li
-- PLC-347: Add Job Profile Assignment type attribute in Job Profile Group Assign screen
CREATE TABLE assignment_type_attribute (user_id nvarchar(85) NOT NULL, job_profile_id nvarchar(15) NOT NULL, attribute_id nvarchar(15) NOT NULL, attribute_value_data nvarchar(2000), update_meaning nvarchar(8), last_updated datetime, updater_legal_name nvarchar(250), update_meaning_text nvarchar (max), last_updater_uid nvarchar(85))
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'assignment_type_attribute'; DECLARE @FullTableName SYSNAME; SET @FullTableName = @DynamicSchemaName + N'.assignment_type_attribute';DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'This table stores details of job profile assignment type attributes';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.name = N'MS_Description' AND ep.minor_id=0); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'assignment_type_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.assignment_type_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'user_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'ID of User';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'assignment_type_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.assignment_type_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'job_profile_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'ID of Job Profile';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'assignment_type_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.assignment_type_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'attribute_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'ID of job profile assignment type attribute';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'assignment_type_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.assignment_type_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'attribute_value_data'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Value of job profile assignment type attribute';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'assignment_type_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.assignment_type_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'update_meaning'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Update Meaning';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'assignment_type_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.assignment_type_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_updated'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Update Datetime';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'assignment_type_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.assignment_type_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'updater_legal_name'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'e-Signature property: legal name of updater';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'assignment_type_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.assignment_type_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'update_meaning_text'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'e-Signature property: update meaning';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'assignment_type_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.assignment_type_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_updater_uid'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'e-Signature property: ID of updater';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

ALTER TABLE assignment_type_attribute ADD CONSTRAINT PK_ASSIGNMENT_TYPE_ATTRIBUTE PRIMARY KEY (user_id, job_profile_id, attribute_id)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20240229-rli-1', 'richard.li', 'nschema/2409.changeLog.xml', GETDATE(), 870, '8:b706575d18b983c9bb9c8958f82fdf5f', 'createTable tableName=assignment_type_attribute; addPrimaryKey constraintName=PK_ASSIGNMENT_TYPE_ATTRIBUTE, tableName=assignment_type_attribute', 'PLC-347: Add Job Profile Assignment type attribute in Job Profile Group Assign screen', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2409.changeLog.xml::20240329-rli-1::richard.li
-- PLC-367: Add Job Profile attribute in Job Profile Editor
CREATE TABLE job_profile_attribute (job_profile_id nvarchar(15) NOT NULL, attribute_id nvarchar(15) NOT NULL, attribute_value_data nvarchar(2000), update_meaning nvarchar(8), last_updated datetime, updater_legal_name nvarchar(250), update_meaning_text nvarchar (max), last_updater_uid nvarchar(85))
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'job_profile_attribute'; DECLARE @FullTableName SYSNAME; SET @FullTableName = @DynamicSchemaName + N'.job_profile_attribute';DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'This table stores details of job profile attributes';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.name = N'MS_Description' AND ep.minor_id=0); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'job_profile_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.job_profile_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'job_profile_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'ID of Job Profile';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'job_profile_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.job_profile_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'attribute_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'ID of job profile attribute';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'job_profile_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.job_profile_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'attribute_value_data'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Value of job profile attribute';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'job_profile_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.job_profile_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'update_meaning'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Update Meaning';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'job_profile_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.job_profile_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_updated'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Update Datetime';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'job_profile_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.job_profile_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'updater_legal_name'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'e-Signature property: legal name of updater';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'job_profile_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.job_profile_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'update_meaning_text'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'e-Signature property: update meaning';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'job_profile_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.job_profile_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_updater_uid'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'e-Signature property: ID of updater';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

ALTER TABLE job_profile_attribute ADD CONSTRAINT PK_JOB_PROFILE_ATTRIBUTE PRIMARY KEY (job_profile_id, attribute_id)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20240329-rli-1', 'richard.li', 'nschema/2409.changeLog.xml', GETDATE(), 871, '8:b01e4bb52588612204e54ed03b29a8fb', 'createTable tableName=job_profile_attribute; addPrimaryKey constraintName=PK_JOB_PROFILE_ATTRIBUTE, tableName=job_profile_attribute', 'PLC-367: Add Job Profile attribute in Job Profile Editor', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2409.changeLog.xml::20240607-rli-1::richard.li
-- PLC-375: Add competency attribute in Competency Editor
CREATE TABLE competency_attribute (competency_id nvarchar(15) NOT NULL, attribute_id nvarchar(15) NOT NULL, attribute_value_data nvarchar(2000), update_meaning nvarchar(8), last_updated datetime, updater_legal_name nvarchar(250), update_meaning_text nvarchar (max), last_updater_uid nvarchar(85))
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'competency_attribute'; DECLARE @FullTableName SYSNAME; SET @FullTableName = @DynamicSchemaName + N'.competency_attribute';DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'This table stores details of competency attributes';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.name = N'MS_Description' AND ep.minor_id=0); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'competency_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.competency_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'competency_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'ID of Competency';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'competency_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.competency_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'attribute_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'ID of competency attribute';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'competency_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.competency_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'attribute_value_data'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Value of competency attribute';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'competency_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.competency_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'update_meaning'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Update Meaning';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'competency_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.competency_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_updated'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Update Datetime';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'competency_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.competency_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'updater_legal_name'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'e-Signature property: legal name of updater';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'competency_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.competency_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'update_meaning_text'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'e-Signature property: update meaning';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'competency_attribute'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.competency_attribute'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_updater_uid'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'e-Signature property: ID of updater';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

ALTER TABLE competency_attribute ADD CONSTRAINT PK_COMPETENCY_ATTRIBUTE PRIMARY KEY (competency_id, attribute_id)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20240607-rli-1', 'richard.li', 'nschema/2409.changeLog.xml', GETDATE(), 872, '8:c045591e7e3a4e4cb1a7e3d4f4033a20', 'createTable tableName=competency_attribute; addPrimaryKey constraintName=PK_COMPETENCY_ATTRIBUTE, tableName=competency_attribute', 'PLC-375: Add competency attribute in Competency Editor', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2409.changeLog.xml::20240626-em-1::emmar.masagca
-- PL-3620 - VILT - MS Teams - Add a function to allow syncing of attendees
ALTER TABLE vc_ms_teams_session ADD update_history_status char(1)
GO

ALTER TABLE vc_ms_teams_session ADD last_update_history_time datetime
GO

ALTER TABLE vc_ms_teams_session ADD last_update_history_uid nvarchar(85)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_session'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_session'; DECLARE @ColumnName SYSNAME set @ColumnName = N'update_history_status'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Status of the update history';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_session'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_session'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_update_history_time'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Last update history time';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'vc_ms_teams_session'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.vc_ms_teams_session'; DECLARE @ColumnName SYSNAME set @ColumnName = N'last_update_history_uid'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Last update history user ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20240626-em-1', 'emmar.masagca', 'nschema/2409.changeLog.xml', GETDATE(), 873, '8:02e120def0118559f0e603bc0722e0c4', 'addColumn tableName=vc_ms_teams_session', 'PL-3620 - VILT - MS Teams - Add a function to allow syncing of attendees', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2409.changeLog.xml::20240704-yf-1::yueqin.feng
-- NSD-9490: Add Forgot password email url setting in Organization and Logical Domain
ALTER TABLE code_orgstructure ADD forget_password_email_link_url nvarchar(255)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'code_orgstructure'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.code_orgstructure'; DECLARE @ColumnName SYSNAME set @ColumnName = N'forget_password_email_link_url'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'The URL used for forget password email link at organization level';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

ALTER TABLE logical_domain ADD forget_password_email_link_url nvarchar(255)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'logical_domain'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.logical_domain'; DECLARE @ColumnName SYSNAME set @ColumnName = N'forget_password_email_link_url'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'The URL used for forget password email link';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20240704-yf-1', 'yueqin.feng', 'nschema/2409.changeLog.xml', GETDATE(), 874, '8:6381cdfa78fc8d820869073dd56c80fd', 'addColumn tableName=code_orgstructure; addColumn tableName=logical_domain', 'NSD-9490: Add Forgot password email url setting in Organization and Logical Domain', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2409.changeLog.xml::20240611-md-1::mark.dacles
-- NSD-9514 [TCC] Session Title limit on CSV formatting help vs database
ALTER TABLE sessiondetail ALTER COLUMN session_title nvarchar(255)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20240611-md-1', 'mark.dacles', 'nschema/2409.changeLog.xml', GETDATE(), 875, '8:14fb73b31e1808dae5bf98c64482dd05', 'modifyDataType columnName=session_title, tableName=sessiondetail', 'NSD-9514 [TCC] Session Title limit on CSV formatting help vs database', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2409.changeLog.xml::20240714-rn-1::ronald.ng
-- PL-7741: Add navigation style field for frameless skin
ALTER TABLE screenLayout ADD navigation_style nvarchar(85) CONSTRAINT DF_screenLayout_navigation_style DEFAULT 'top' NOT NULL
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'screenLayout'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.screenLayout'; DECLARE @ColumnName SYSNAME set @ColumnName = N'navigation_style'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'define navigation style for frameless skin, e.g. left';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

UPDATE screenLayout SET navigation_style = 'left' WHERE shortname LIKE '%PeopleFluent_%Default%' AND directory='lms-skin'
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20240714-rn-1', 'ronald.ng', 'nschema/2409.changeLog.xml', GETDATE(), 876, '8:dcbddeac848d0986bd30d319eb1524d5', 'addColumn tableName=screenLayout; update tableName=screenLayout', 'PL-7741: Add navigation style field for frameless skin', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2409.changeLog.xml::20240722-rn-2::ronald.ng
-- PL-7839: New Function: Bookmarked Features
CREATE TABLE bookmarks (assignment_id nvarchar(85) NOT NULL, tx_code nvarchar(255) NOT NULL, parameters nvarchar(85) NOT NULL, creation_date datetime NOT NULL)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'bookmarks'; DECLARE @FullTableName SYSNAME; SET @FullTableName = @DynamicSchemaName + N'.bookmarks';DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'This table stores bookmarks saved by users';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.name = N'MS_Description' AND ep.minor_id=0); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'bookmarks'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.bookmarks'; DECLARE @ColumnName SYSNAME set @ColumnName = N'assignment_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Assignment ID';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'bookmarks'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.bookmarks'; DECLARE @ColumnName SYSNAME set @ColumnName = N'tx_code'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'TX Code';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'bookmarks'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.bookmarks'; DECLARE @ColumnName SYSNAME set @ColumnName = N'parameters'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'TX Parameters';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'bookmarks'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.bookmarks'; DECLARE @ColumnName SYSNAME set @ColumnName = N'creation_date'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Bookmark Creation Date';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

ALTER TABLE bookmarks ADD CONSTRAINT PK_BOOKMARKS PRIMARY KEY (assignment_id, tx_code, parameters)
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20240722-rn-2', 'ronald.ng', 'nschema/2409.changeLog.xml', GETDATE(), 877, '8:cd45635c0d57bca481a1cb6cc54da19d', 'createTable tableName=bookmarks; addPrimaryKey constraintName=PK_BOOKMARKS, tableName=bookmarks', 'PL-7839: New Function: Bookmarked Features', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2409.changeLog.xml::20240814-jw-1::justin.wang
-- PLC-337 LTI Tool Course Integration - add new field
ALTER TABLE lti_tool ADD connector_id nvarchar(255)
GO

DECLARE @DynamicSchemaName SYSNAME set @DynamicSchemaName = SCHEMA_NAME();
DECLARE @TableName SYSNAME set @TableName = N'lti_tool'; DECLARE @FullTableName SYSNAME set @FullTableName = @DynamicSchemaName + N'.lti_tool'; DECLARE @ColumnName SYSNAME set @ColumnName = N'connector_id'; DECLARE @MS_DescriptionValue NVARCHAR(3749); SET @MS_DescriptionValue = N'Unique identifier of the Content Connector';DECLARE @MS_Description NVARCHAR(3749) set @MS_Description = NULL; SET @MS_Description = (SELECT CAST(Value AS NVARCHAR(3749)) AS [MS_Description] FROM sys.extended_properties AS ep WHERE ep.major_id = OBJECT_ID(@FullTableName) AND ep.minor_id=COLUMNPROPERTY(ep.major_id, @ColumnName, 'ColumnId') AND ep.name = N'MS_Description'); IF @MS_Description IS NULL BEGIN EXEC sys.sp_addextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END ELSE BEGIN EXEC sys.sp_updateextendedproperty @name  = N'MS_Description', @value = @MS_DescriptionValue, @level0type = N'SCHEMA', @level0name = @DynamicSchemaName, @level1type = N'TABLE', @level1name = @TableName, @level2type = N'COLUMN', @level2name = @ColumnName; END
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20240814-jw-1', 'justin.wang', 'nschema/2409.changeLog.xml', GETDATE(), 878, '8:a98e0d5c78ea0f17b78cb7655d9c4e68', 'addColumn tableName=lti_tool', 'PLC-337 LTI Tool Course Integration - add new field', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2409.changeLog.xml::20240814-jw-2::justin.wang
-- PLC-337 LTI Tool Course Integration- change db schema
exec sp_rename 'lti_tool.max_inactive_interval', 'access_token_url'
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20240814-jw-2', 'justin.wang', 'nschema/2409.changeLog.xml', GETDATE(), 879, '8:03153b1d600ef805b8cb08d9453bb669', 'renameColumn newColumnName=access_token_url, oldColumnName=max_inactive_interval, tableName=lti_tool', 'PLC-337 LTI Tool Course Integration- change db schema', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/2409.changeLog.xml::20240829-rn-1::ronald.ng
-- PL-7868: Backend Prep for New Skin Release
UPDATE screenLayout SET legacymode = 'N', mouseovermenu = 'N' WHERE shortname LIKE '%PeopleFluent_%Default%' AND directory='lms-skin'
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20240829-rn-1', 'ronald.ng', 'nschema/2409.changeLog.xml', GETDATE(), 880, '8:b86eff0eaf9c7b872fa327ccec1add27', 'update tableName=screenLayout', 'PL-7868: Backend Prep for New Skin Release', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/sys.initializer.changeLog.xml::20140117-sg-01::shravan
INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('INITIALIZED', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('60_1;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('60_2;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('60_3;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('60_4;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('61_1;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('61_3;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('61_4;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('62_1;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('62_3;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('63_1;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('63_3;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('63_4;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('63_7;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('70_1;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('70_2;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('70_3;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('70_4;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('71_1;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('71_3;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('71_4;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('72_1;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('80_2;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('82_1;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('83_1;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('90_1;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('90_2;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('90_4;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('90_5;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('90_6;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('91_1;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('91_2;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('91_3;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('91_4;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('91_5;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('91_6;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('91_7;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('91_8;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('91_9;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('91_10;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('91_11;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('91_12;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('91_13;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('91_14;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('92_1;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('92_3;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('92_4;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('92_5;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('93_1;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('93_2;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('93_3;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('93_4;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('100_1;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('100_2;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('100_3;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('100_5;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('100_6;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('101_1;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('101_2;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('101_3;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('101_4;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('101_5;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('102_1;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('102_2;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('102_3;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('102_4;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('102_5;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('103_5;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('110_1;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('111_1;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('111_2;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('111_3;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('111_4;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('111_5;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('111_6;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('111_7;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('1111_1;', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('1111_2', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('1111_3', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('1111_4', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('1112_1', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('1112_2', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('112_0', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('112_1', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('112_2', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('1121_2', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('121_7', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('122_1', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('122_2', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('122_5', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('122_6', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('130_2', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('131_1', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('131_5', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('131_6', GETDATE())
GO

INSERT INTO system_migration_tasks (taskid, action_date) VALUES ('140_1', GETDATE())
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20140117-sg-01', 'shravan', 'nschema/sys.initializer.changeLog.xml', GETDATE(), 881, '8:ff0dd506d5ae23291526f337556b9088', 'insert tableName=system_migration_tasks; insert tableName=system_migration_tasks; insert tableName=system_migration_tasks; insert tableName=system_migration_tasks; insert tableName=system_migration_tasks; insert tableName=system_migration_tasks; i...', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/sys.initializer.changeLog.xml::20150122-sg-01::shravan.gurrala
INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20150122-sg-01', 'shravan.gurrala', 'nschema/sys.initializer.changeLog.xml', GETDATE(), 882, '8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/sys.initializer.changeLog.xml::20150423-dc-01::dennis.cheung
DELETE FROM code_itemLanguage
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20150423-dc-01', 'dennis.cheung', 'nschema/sys.initializer.changeLog.xml', GETDATE(), 883, '8:46ff72ccfa606a2e12a677aeacfaa466', 'delete tableName=code_itemLanguage', '', 'EXECUTED', NULL, NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/sys.initializer.changeLog.xml::20200908-yf-02::yueqin.feng
-- PL-375: Replacement Default Skin
UPDATE screenLayout SET bottomContent = 0, bottomHeight = '0', bottomMenu = 100, bottomStylesheet = 'bottom.css', bottomTX = NULL, description = 'PeopleFluent_LMS_Default', directory = 'lms-skin', displaySearchBox = 'Y', fixed_width = 0, frameless = 'Y', homeTX = 'WIDGETCONTAINERPAGE', homepage_template = 'DEFAULTTEMPLATE', iconset = 0, language = 0, layout = 4, leftContent = 0, leftMenu = 100, leftStylesheet = 'left.css', leftTX = NULL, leftWidth = '0', mainContent = 0, mainMenu = 100, mainStylesheet = 'main.css', menu_position = 'N', mouseovermenu = 'Y', right_to_left = 'N', shortname = 'PeopleFluent_LMS_Default', showteachbutton = 'Y', topContent = 0, topHeight = '0', topMenu = 100, topStylesheet = 'top.css', topTX = NULL, usetab = 'Y' WHERE ui = 0
GO

DELETE FROM screenLayout WHERE ui = 15
GO

DELETE FROM permissions WHERE objecttype='SKIN' AND objectid='15'
GO

DELETE FROM permission_mapping WHERE objecttype='SKIN' AND objectid='15'
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20200908-yf-02', 'yueqin.feng', 'nschema/sys.initializer.changeLog.xml', GETDATE(), 884, '8:16e02e8fbe693d7ea4f7ae5180412127', 'update tableName=screenLayout; delete tableName=screenLayout; delete tableName=permissions; delete tableName=permission_mapping', 'PL-375: Replacement Default Skin', 'EXECUTED', '93', NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/sys.initializer.changeLog.xml::20201102-yf-02::yueqin.feng
-- PL-600: Make new home page default home page
UPDATE screenLayout SET homeTX = 'HOMEPAGE' WHERE ui = 0
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20201102-yf-02', 'yueqin.feng', 'nschema/sys.initializer.changeLog.xml', GETDATE(), 885, '8:cbb258eb7defd3be180cf321f9f9a28b', 'update tableName=screenLayout', 'PL-600: Make new home page default home page', 'EXECUTED', '93', NULL, '4.8.0', '6820121693')
GO

-- Changeset nschema/sys.initializer.changeLog.xml::20240906-yf-01::yueqin.feng
-- PL-7868: Backend Prep for New Skin Release
UPDATE screenLayout SET legacymode = 'N', mouseovermenu = 'N', navigation_style = 'left', primary_color = '#1F3055', secondary_color = '#2A4072' WHERE ui = 0
GO

INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('20240906-yf-01', 'yueqin.feng', 'nschema/sys.initializer.changeLog.xml', GETDATE(), 886, '8:aad5fc47157953777d7acb08c2b928eb', 'update tableName=screenLayout', 'PL-7868: Backend Prep for New Skin Release', 'EXECUTED', '93', NULL, '4.8.0', '6820121693')
GO

-- Release Database Lock
UPDATE DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1
GO

