So here I am, once again, not satisfied with the answer. I was tasked to upgrade JIRA 6.4.x to JIRA Software 7.x and I went to that particular problem with the database and column collation.
In SQL Server, if you do not drop constrains such as primary key or foreign key or even indexes, the script provided above as an answer doesn't work at all. It will however change those without those properties. This is really problematic, because I don't want to manually drop all constrains and create them back. That operation could probably ends up with errors. On the other side, creating a script automating the change could take ages to make.
So I found a way to make the migration simply by using SQL Management Studio. Here's the procedure:
- Rename the database by something else. By example, mine's was "Jira", so I renamed it "JiraTemp".
- Create a new database named "Jira" and make sure to set the right collation. Simply select the page "Options" and change the collation.
- Once created, go back to "JiraTemp", right click it, "Tasks -> Generate Scripts...".
- Select "Script entire database and all database objects".
- Select "Save to new query window", then select "Advanced"
- Change the value of "Script for Server Version" for the desired value
- Enable "Script Object-Level Permissions", "Script Owner" and "Script Full-Text Indexes"
- Leave everything else as is or personalize it if you wish.
- Once generated, delete the "CREATE DATABASE" section. Replace "JiraTemp" by "Jira".
- Run the script. The entire database structure and permissions of the database is now replicated to "Jira".
- Before we copy the data, we need to disable all constrains. Execute the following command to do so in the database "Jira":
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
- Now the data needs to be transferred. To do so, simply right click "JiraTemp", then select "Tasks -> Export Data..."
- Select as data source and destination the OLE DB Provider for SQL Server.
- Source database is "JiraTemp"
- Destination database is "Jira"
- The server name is technically the same for source and destination (except if you've created the database on another server).
- Select "Copy data from one or another tables or views"
- Select all tables except views. Then, when still highlighted, click on "Edit Mappings". Check "Enable identity insert"
- Click OK, Next, then Finish
- Data transfer can take a while. Once finished, execute the following command to re enable all constrains:
exec sp_msforeachtable @command1="print '?'", @command2="ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"
Once completed, I've restarted JIRA and my database collation was in order. Hope it helps a lot of people!