Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

reraise exception with intsructions in ICU collation migration

Ivan Kuchin4a939aff3714
diff --git a/db/migrate/20240920152544_set_versions_name_collation.rb b/db/migrate/20240920152544_set_versions_name_collation.rb
index 1109bf9eec4..cbfb9541b8c 100644
--- a/db/migrate/20240920152544_set_versions_name_collation.rb
+++ b/db/migrate/20240920152544_set_versions_name_collation.rb
@@ -1,8 +1,23 @@
class SetVersionsNameCollation < ActiveRecord::Migration[7.1]
def up
- execute <<-SQL.squish
- CREATE COLLATION IF NOT EXISTS versions_name (provider = icu, locale = 'und-u-kn-true');
- SQL
+ begin
+ execute <<-SQL.squish
+ CREATE COLLATION IF NOT EXISTS versions_name (provider = icu, locale = 'und-u-kn-true');
+ SQL
+ rescue StandardError => e
+ raise unless e.message.include?("encoding")
+
+ abort <<~MESSAGE
+ \e[31mERROR:\e[0m Failed to create an ICU collation with current database encoding.
+ You need to change the database encoding before proceeding.
+
+ Please check the instructions on how to do it:
+ https://www.openproject.org/docs/installation-and-operations/misc/changing-database-encoding/
+
+ Original error:
+ #{e.message}
+ MESSAGE
+ end
change_column :versions, :name, :string, collation: "versions_name"
end