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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
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', '1179394455')
GO

-- Changeset nschema/2111.changeLog.xml::20210914-ct-4::craig.taylor
-- PL-2355: Rustici property settings
