Skip to content

Commit

Permalink
reraise exception with intsructions in ICU collation migration
Browse files Browse the repository at this point in the history
  • Loading branch information
toy committed Nov 20, 2024
1 parent d142302 commit 4a939af
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions db/migrate/20240920152544_set_versions_name_collation.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 4a939af

Please sign in to comment.