From 8135e08107f81c38389ec3938df85a9b9f0e1f4f Mon Sep 17 00:00:00 2001 From: erdgeist Date: Sun, 9 Aug 2026 22:14:29 +0200 Subject: Load the test schema through Rails, and keep the search trigger installed --- INSTALL.md | 3 +++ lib/tasks/init.rake | 4 ++++ lib/tasks/test_db.rake | 19 ------------------- test/test_helper.rb | 6 ++++++ 4 files changed, 13 insertions(+), 19 deletions(-) delete mode 100644 lib/tasks/test_db.rake diff --git a/INSTALL.md b/INSTALL.md index cad9c9e1..55bf768c 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -134,6 +134,9 @@ test: database: psql_test username: rails password: + collation: en_US.UTF-8 + ctype: en_US.UTF-8 + template: template0 production: adapter: postgresql diff --git a/lib/tasks/init.rake b/lib/tasks/init.rake index 16575345..adfaddfd 100644 --- a/lib/tasks/init.rake +++ b/lib/tasks/init.rake @@ -77,3 +77,7 @@ namespace :cccms do end end end + +Rake::Task["db:schema:load"].enhance do + Page.ensure_search_vector_trigger! +end diff --git a/lib/tasks/test_db.rake b/lib/tasks/test_db.rake deleted file mode 100644 index 0a7a17d7..00000000 --- a/lib/tasks/test_db.rake +++ /dev/null @@ -1,19 +0,0 @@ -namespace :db do - namespace :test do - task :load_schema do - ActiveRecord::Base.establish_connection(:test) - ActiveRecord::Schema.verbose = false - load "#{Rails.root}/db/schema.rb" - end - - task :prepare => :environment do - begin - ActiveRecord::Base.establish_connection(:test) - ActiveRecord::Base.connection - rescue - system("psql -U postgres postgres -c \"CREATE DATABASE psql_test OWNER psql ENCODING 'UTF8';\"") - end - Rake::Task['db:test:load_schema'].invoke - end - end -end diff --git a/test/test_helper.rb b/test/test_helper.rb index 7ab9c8c9..b7fe2b58 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,6 +2,12 @@ ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'rails/test_help' +# rails/test_help calls maintain_test_schema!, which reloads db/schema.rb +# in this process when a migration is pending. That recreates +# page_translations and drops the search_vector trigger the initializer +# installed at boot. Reinstall it here, after any such reload. +Page.ensure_search_vector_trigger! + module ActiveRecord class FixtureSet class << self -- cgit v1.3