How to fix the collation of Microsoft SQL Server database for Jira manually
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Fisheye および Crucible は除く
目的
If your Microsoft SQL Server database doesn't use the recommended collation you can run this procedure to bring them into line with the
- JIRA の SQL Server 2005 への接続
- JIRA の SQL Server 2008 への接続
- Connecting JIRA to SQL Server 2012
- Connecting JIRA to SQL Server 2016
- Connecting JIRA to SQL Server 2017
- Connecting JIRA to SQL Server 2019
この手順は、2 つのサーバー間で適切な照合を保持しながら SQL Server データベースを移動するためにも使用できます。 データベースの直接操作はアトラシアンのサポート内容に含まれておらず、データベース管理者がご自身の責任で行う必要があります。
アトラシアンが推奨するデータベースの移行方法は次のとおりです。
- 「Jira をデータベースに接続する」内の手順に従い、必要な照合で新しいデータベースを作成します。
- Follow our Switching Databases using an XML backup to migrate JIRA from the old databases (with the incorrect collation) to the new one, with the correct collation.
If the recommended method for some reason is not suitable for your scenario, please follow the Solution section below to manually fix the collation at the database server side manually
ソリューション
はじめる前に
データベースの変更を行う場合は必ず事前にバックアップを取得してください。可能な場合は、まずステージング サーバーで SQL コマンドの変更、挿入、更新、または削除を行うようにします。
The steps outlined on this article are provided AS-IS. This means we've had reports of them working for some customers — under certain circumstances — yet are not officially supported, nor can we guarantee they'll work for your specific scenario — though you may try them out. As the steps below pertain to direct database manipulations, we strongly recommend engaging your DBA to assist with the procedure.
You may follow through and validate them on your own non-prod environment prior to production or fall back to supported alternatives if they don't work out.
We also invite you to reach out to our Community for matters that fall beyond Atlassian's scope of support!
Portfolio for JIRA: For instances that do have Portfolio for JIRA installed, please note on Plans missing in Advanced Roadmaps for Jira after updating SQL Server Collation KB article before applying the database update change below.
To run this procedure SQL Server Management Studio needs to be in version 2008, if you are still using SQL Server Management Studio 2005, you will need to upgrade it to at least 2008 or migrate your JIRA database to SQL Server Management 2008 or latest.
診断
The following line is being thrown in atlassian-jira.log:
****************************************************************************************************
You are using an unsupported mssql collation: SQL_Latin1_General_CP1_CI_AS. This may cause some functionality to not work.
Please use SQL_Latin1_General_CP437_CI_AI or Latin1_General_CI_AI as the collation instead.
****************************************************************************************************
Run the following query against your old database. If it returns any results, you must adjust the collation.
SELECT object_name(object_id) as TableName, name as ColumnName, collation_name
FROM sys.columns
WHERE collation_name != 'SQL_Latin1_General_CP437_CI_AI' AND collation_name != 'Latin1_General_CI_AI'
AND object_name(object_id) NOT LIKE 'sys%'
AND object_name(object_id) NOT LIKE 'queue%'
AND object_name(object_id) NOT LIKE 'file%'
AND object_name(object_id) NOT LIKE 'spt%'
AND object_name(object_id) NOT LIKE 'MSrep%'
AND object_name(object_id) NOT LIKE 'sqlagent%'
AND object_name(object_id) NOT LIKE 'plan_persist%'
Create the new Database
Firstly, create a new database as per our guidelines linked above in the 'Purpose' section. It is important that the new database is configured correctly from the start, for example the isolation levels need to be set and the collation should be set to SQL_Latin1_General_CP437_CI_AI or
Latin1_General_CI_AI, depending of the the version of supported by JIRA and your preference.
Create the Database Tables
We'll create the database tables from your existing database. In SQL Server Management Studio, right click on your old database:
- Click Tasks > Generate Scripts...;
- In the Choose Objects screen, choose Select specific database objects;
- Tick Tables - this selects all the objects in the database, but not the database itself (since we already created a new database);
- On the Set Scripting Options click Advanced and adjust the following options:
- Set Script USE DATABASE to false;
- Set Script Full-Text Indexes to true;
- Set Script Indexes to true;
- Click Next, then Finish;
- 新しいデータベースに対してスクリプトを実行します。この時点で新しいデータベースにはテーブルが含まれますがデータは含まれません。
Disable "Constraint Checks" before importing
データをインポートする前に、データベース内のすべてのテーブルで制約チェックを一時的に無効化する必要があります。新しいデータベースに対して次のクエリを実行します。
EXEC sp_MSforeachtable"ALTER TABLE ? NOCHECK CONSTRAINT all"
Import data from the old database
エクスポート ウィザードが完了すると同じ名前の 2 つのデータベースが作成されるため、このセクションを始める前に十分なディスク容量があることを確認してください。
In SQL Server Management Studio, right click on your old database:
- Click Tasks > Export Data...;
- In the Choose a Data Source screen, ensure your old database is selected. Then click Next;
- In the Choose a Destination screen, provide the connection information for your new database. Usually, this will be the same server, however, you can use any SQL Server you can authenticate against. Then click Next;
- Choose Copy data from one or more tables or views then click Next;
- In the Select Source Tables and Views, ensure all tables are ticked, and that all tables have been highlighted;
- With the tables highlighted, click Edit Mappings...
- Ensure the correct schema has been selected (
dbo
is usually the correct schema) and that Enable Identity Insert has been ticked. Click OK; - Click Next and complete the transfer of data. Depending on the size of the database, and the speed of the database server(s) being used, this process will take time.
Re-enable Constraint Checks after importing
インポートが完了したら、データベースの制約チェックを再有効化する必要があります。新しいデータベースに対して次のクエリを実行します。
EXEC sp_MSforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"
Check the collation is correct
Run the diagnosis query again, to ensure that there are no rows with the incorrect collation.
Point JIRA to the new database
- Jira を停止します。
- Backup your JIRA Home Directory and Installation Directory.
- Reconfigure the connection to your database:
- Open the
<jira-home>/dbconfig.xml
file - Locate the
<url>
tag Change the name of the database (the one after the last slash) to your new database. For example,
<url>jdbc:jtds:sqlserver://dbserver:1433/
old_db</url>
would be changed to
<url>jdbc:jtds:sqlserver://dbserver:1433/
new_db</url>
- Save the file
- Start JIRA and check everything is working.
お困りですか?
Create a new database with the required collation as per the appropriate documentation in Connecting JIRA to a Database.
Follow our Switching Databases using an XML backup to migrate JIRA from the old databases (with the incorrect collation) to the new one, with the correct collation.