You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: 20230328154645_add_gin_trgm_index_on_journals_and_custom_values.rb
    path of file: ./repos/openproject/db/migrate
    
    the code of the file until where you have to start completion: #-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2024 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyr
    
  def safe_enable_pg_trgm_extension
    ActiveRecord::Base.connection.execute("CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA pg_catalog;")
  rescue StandardError => e
    raise unless e.message.include?('pg_trgm')

    # Rollback the transaction in order to recover from the error.
    ActiveRecord::Base.connection.execute 'ROLLBACK'

    warn <<~MESSAGE


      \e[33mWARNING:\e[0m Could not find the `pg_trgm` extension for PostgreSQL.
      In order to benefit from this performance improvement, please install the postgresql-contrib module
      for your PostgreSQL installation and re-run this migration.

      Read more about the contrib module at `https://www.postgresql.org/docs/current/contrib.html` .
      To re-run this migration use the following command `bin/rails db:migrate:redo VERSION=20230328154645`

    MESSAGE
  end