EXEC sp_rename 'notification.TYPE', 'NOTIF_TYPE', 'COLUMN';
EXEC sp_rename 'notification.PARAMETER', 'NOTIF_PARAMETER', 'COLUMN';
EXEC sp_rename 'mailserver.TYPE', 'SERVER_TYPE', 'COLUMN';
EXEC sp_rename 'jiraeventtype.TYPE', 'EVENT_TYPE', 'COLUMN';
EXEC sp_rename 'schemepermissions.TYPE', 'PERM_TYPE', 'COLUMN';
EXEC sp_rename 'schemepermissions.PARAMETER', 'PERM_PARAMETER', 'COLUMN';
EXEC sp_rename 'fieldlayout.TYPE', 'LAYOUT_TYPE', 'COLUMN';
EXEC sp_rename 'schemeissuesecurities.TYPE', 'SEC_TYPE', 'COLUMN';
EXEC sp_rename 'schemeissuesecurities.PARAMETER', 'SEC_PARAMETER', 'COLUMN';
EXEC sp_rename 'portletconfiguration.POSITION', 'POSITIONSEQ', 'COLUMN';
EXEC sp_rename 'version', 'projectversion';
GO

-- change the type from TEXT to NTEXT in order to handle i18n characters

-- change jiraissue.description to NTEXT using temp column tempdescription
alter table jiraissue add tempdescription NTEXT
GO
update jiraissue set tempdescription = description
GO
alter table jiraissue drop column description
GO
sp_rename 'jiraissue.tempdescription','description','COLUMN'
GO

-- change jiraissue.environment to NTEXT using temp column tempenvironment
alter table jiraissue add tempenvironment NTEXT
GO
update jiraissue set tempenvironment = environment
GO
alter table jiraissue drop column environment
GO
sp_rename 'jiraissue.tempenvironment','environment','COLUMN'
GO

-- change jiraaction.actionbody to NTEXT using temp column tempactionbody
alter table jiraaction add tempactionbody NTEXT
GO
update jiraaction set tempactionbody = actionbody
GO
alter table jiraaction drop column actionbody
GO
sp_rename 'jiraaction.tempactionbody','actionbody','COLUMN'
GO

-- change customfieldvalue.textvalue to NTEXT using temp column temptextvalue
alter table customfieldvalue add temptextvalue NTEXT
GO
update customfieldvalue set temptextvalue = textvalue
GO
alter table customfieldvalue drop column textvalue
GO
sp_rename 'customfieldvalue.temptextvalue','textvalue','COLUMN'
GO

-- change changeitem.oldvalue to NTEXT using temp column tempoldvalue
alter table changeitem add tempoldvalue NTEXT
GO
update changeitem set tempoldvalue = oldvalue
GO
alter table changeitem drop column oldvalue
GO
sp_rename 'changeitem.tempoldvalue','oldvalue','COLUMN'
GO
-- change changeitem.oldstring to NTEXT using temp column tempoldstring
alter table changeitem add tempoldstring NTEXT
GO
update changeitem set tempoldstring = oldstring
GO
alter table changeitem drop column oldstring
GO
sp_rename 'changeitem.tempoldstring','oldstring','COLUMN'
GO
-- change changeitem.newvalue to NTEXT using temp column tempnewvalue
alter table changeitem add tempnewvalue NTEXT
GO
update changeitem set tempnewvalue = newvalue
GO
alter table changeitem drop column newvalue
GO
sp_rename 'changeitem.tempnewvalue','newvalue','COLUMN'
GO
-- change changeitem.newstring to NTEXT using temp column tempnewstring
alter table changeitem add tempnewstring NTEXT
GO
update changeitem set tempnewstring = newstring
GO
alter table changeitem drop column newstring
GO
sp_rename 'changeitem.tempnewstring','newstring','COLUMN'
GO

-- change jiraworkflows.descriptor to NTEXT using temp column tempdescriptor
alter table jiraworkflows add tempdescriptor NTEXT
GO
update jiraworkflows set tempdescriptor = descriptor
GO
alter table jiraworkflows drop column descriptor
GO
sp_rename 'jiraworkflows.tempdescriptor','descriptor','COLUMN'
GO

-- change propertystring.propertyvalue to NTEXT using temp column temppropertyvalue
alter table propertystring add temppropertyvalue NTEXT
GO
update propertystring set temppropertyvalue = propertyvalue
GO
alter table propertystring drop column propertyvalue
GO
sp_rename 'propertystring.temppropertyvalue','propertyvalue','COLUMN'
GO
-- change propertytext.propertyvalue to NTEXT using temp column temppropertyvalue
alter table propertytext add temppropertyvalue NTEXT
GO
update propertytext set temppropertyvalue = propertyvalue
GO
alter table propertytext drop column propertyvalue
GO
sp_rename 'propertytext.temppropertyvalue','propertyvalue','COLUMN'
GO
-- change project.description to NTEXT using temp column tempdescription
alter table project add tempdescription NTEXT
GO
update project set tempdescription = description
GO
alter table project drop column description
GO
sp_rename 'project.tempdescription','description','COLUMN'
GO
-- change projectversion.description to NTEXT using temp column tempdescription
alter table projectversion add tempdescription NTEXT
GO
update projectversion set tempdescription = description
GO
alter table projectversion drop column description
GO
sp_rename 'projectversion.tempdescription','description','COLUMN'
GO
-- change component.description to NTEXT using temp column tempdescription
alter table component add tempdescription NTEXT
GO
update component set tempdescription = description
GO
alter table component drop column description
GO
sp_rename 'component.tempdescription','description','COLUMN'
GO
-- change projectcategory.description to NTEXT using temp column tempdescription
alter table projectcategory add tempdescription NTEXT
GO
update projectcategory set tempdescription = description
GO
alter table projectcategory drop column description
GO
sp_rename 'projectcategory.tempdescription','description','COLUMN'
GO
-- change searchrequest.description to NTEXT using temp column tempdescription
alter table searchrequest add tempdescription NTEXT
GO
update searchrequest set tempdescription = description
GO
alter table searchrequest drop column description
GO
sp_rename 'searchrequest.tempdescription','description','COLUMN'
GO
-- change searchrequest.reqcontent to NTEXT using temp column tempreqcontent
alter table searchrequest add tempreqcontent NTEXT
GO
update searchrequest set tempreqcontent = reqcontent
GO
alter table searchrequest drop column reqcontent
GO
sp_rename 'searchrequest.tempreqcontent','reqcontent','COLUMN'
GO
-- change priority.description to NTEXT using temp column tempdescription
alter table priority add tempdescription NTEXT
GO
update priority set tempdescription = description
GO
alter table priority drop column description
GO
sp_rename 'priority.tempdescription','description','COLUMN'
GO
-- change resolution.description to NTEXT using temp column tempdescription
alter table resolution add tempdescription NTEXT
GO
update resolution set tempdescription = description
GO
alter table resolution drop column description
GO
sp_rename 'resolution.tempdescription','description','COLUMN'
GO
-- change issuetype.description to NTEXT using temp column tempdescription
alter table issuetype add tempdescription NTEXT
GO
update issuetype set tempdescription = description
GO
alter table issuetype drop column description
GO
sp_rename 'issuetype.tempdescription','description','COLUMN'
GO
-- change issuestatus.description to NTEXT using temp column tempdescription
alter table issuestatus add tempdescription NTEXT
GO
update issuestatus set tempdescription = description
GO
alter table issuestatus drop column description
GO
sp_rename 'issuestatus.tempdescription','description','COLUMN'
GO
-- change customfield.description to NTEXT using temp column tempdescription
alter table customfield add tempdescription NTEXT
GO
update customfield set tempdescription = description
GO
alter table customfield drop column description
GO
sp_rename 'customfield.tempdescription','description','COLUMN'
GO
-- change fieldconfigscheme.description to NTEXT using temp column tempdescription
alter table fieldconfigscheme add tempdescription NTEXT
GO
update fieldconfigscheme set tempdescription = description
GO
alter table fieldconfigscheme drop column description
GO
sp_rename 'fieldconfigscheme.tempdescription','description','COLUMN'
GO
-- change fieldconfiguration.description to NTEXT using temp column tempdescription
alter table fieldconfiguration add tempdescription NTEXT
GO
update fieldconfiguration set tempdescription = description
GO
alter table fieldconfiguration drop column description
GO
sp_rename 'fieldconfiguration.tempdescription','description','COLUMN'
GO
-- change genericconfiguration.xmlvalue to NTEXT using temp column tempxmlvalue
alter table genericconfiguration add tempxmlvalue NTEXT
GO
update genericconfiguration set tempxmlvalue = xmlvalue
GO
alter table genericconfiguration drop column xmlvalue
GO
sp_rename 'genericconfiguration.tempxmlvalue','xmlvalue','COLUMN'
GO
-- change mailserver.description to NTEXT using temp column tempdescription
alter table mailserver add tempdescription NTEXT
GO
update mailserver set tempdescription = description
GO
alter table mailserver drop column description
GO
sp_rename 'mailserver.tempdescription','description','COLUMN'
GO
-- change notificationscheme.description to NTEXT using temp column tempdescription
alter table notificationscheme add tempdescription NTEXT
GO
update notificationscheme set tempdescription = description
GO
alter table notificationscheme drop column description
GO
sp_rename 'notificationscheme.tempdescription','description','COLUMN'
GO
-- change jiraeventtype.description to NTEXT using temp column tempdescription
alter table jiraeventtype add tempdescription NTEXT
GO
update jiraeventtype set tempdescription = description
GO
alter table jiraeventtype drop column description
GO
sp_rename 'jiraeventtype.tempdescription','description','COLUMN'
GO
-- change permissionscheme.description to NTEXT using temp column tempdescription
alter table permissionscheme add tempdescription NTEXT
GO
update permissionscheme set tempdescription = description
GO
alter table permissionscheme drop column description
GO
sp_rename 'permissionscheme.tempdescription','description','COLUMN'
GO
-- change issuesecurityscheme.description to NTEXT using temp column tempdescription
alter table issuesecurityscheme add tempdescription NTEXT
GO
update issuesecurityscheme set tempdescription = description
GO
alter table issuesecurityscheme drop column description
GO
sp_rename 'issuesecurityscheme.tempdescription','description','COLUMN'
GO
-- change schemeissuesecuritylevels.description to NTEXT using temp column tempdescription
alter table schemeissuesecuritylevels add tempdescription NTEXT
GO
update schemeissuesecuritylevels set tempdescription = description
GO
alter table schemeissuesecuritylevels drop column description
GO
sp_rename 'schemeissuesecuritylevels.tempdescription','description','COLUMN'
GO
-- change qrtz_calendars.calendar to NTEXT using temp column tempcalendar
alter table qrtz_calendars add tempcalendar NTEXT
GO
update qrtz_calendars set tempcalendar = calendar
GO
alter table qrtz_calendars drop column calendar
GO
sp_rename 'qrtz_calendars.tempcalendar','calendar','COLUMN'
GO
-- change fieldlayoutscheme.description to NTEXT using temp column tempdescription
alter table fieldlayoutscheme add tempdescription NTEXT
GO
update fieldlayoutscheme set tempdescription = description
GO
alter table fieldlayoutscheme drop column description
GO
sp_rename 'fieldlayoutscheme.tempdescription','description','COLUMN'
GO
-- change fieldlayoutitem.description to NTEXT using temp column tempdescription
alter table fieldlayoutitem add tempdescription NTEXT
GO
update fieldlayoutitem set tempdescription = description
GO
alter table fieldlayoutitem drop column description
GO
sp_rename 'fieldlayoutitem.tempdescription','description','COLUMN'
GO
-- change workflowscheme.description to NTEXT using temp column tempdescription
alter table workflowscheme add tempdescription NTEXT
GO
update workflowscheme set tempdescription = description
GO
alter table workflowscheme drop column description
GO
sp_rename 'workflowscheme.tempdescription','description','COLUMN'
GO
