Closed otegami closed 8 months ago
I found a related issue in Rails that seems to be the cause of the problem I faced. This issue has already been fixed in Rails version 7.
To test if this is really related to this problem, I ran the following command:
% plugins/full_text_search/dev/initialize-redmine.sh
Additionally, I modified the pgroonga_text_term_search_ops name to pgroonga_text_term_search_ops_v2 by adding a v2 suffix in db/schema.rb.
# db/schema.rb
create_table "fts_query_expansions", force: :cascade do |t|
t.text "source", null: false
t.text "destination", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["source", "destination"], name: "fts_query_expansions_index_pgroonga", opclass: :pgroonga_text_term_search_ops, using: :pgroonga
t.index ["updated_at"], name: "index_fts_query_expansions_on_updated_at"
end
Although there are still some errors, the main problem seems to be fixed.
% plugins/full_text_search/dev/run-test.sh (git)-[5.1-stable]-
++ grep '^gem '\''rails'\''' Gemfile
++ grep -o '[0-9]*'
++ head -n1
+ rails_version_major=6
+ '[' 6 -ge 6 ']'
+ env PSQLRC=/tmp/nonexistent RAILS_ENV=test ruby bin/rails test 'plugins/*/test/**/*_test.rb'
PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from /Users/otegami/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activerecord-6.1.7.6/lib/active_record/connection_adapters/postgresql_adapter.rb:883:in `new'
PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from /Users/otegami/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activerecord-6.1.7.6/lib/active_record/connection_adapters/postgresql_adapter.rb:883:in `new'
Run options: --seed 28583
# Running:
.......................................E
Error:
FullTextSearch::SearchControllerTest::ChangeRootURLTest#test_api:
NoMethodError: undefined method `filechanges' for nil:NilClass
plugins/full_text_search/test/functional/full_text_search/search_controller_test.rb:556:in `test_api'
rails test plugins/full_text_search/test/functional/full_text_search/search_controller_test.rb:554
E
Error:
FullTextSearch::SearchControllerTest::ChangeRootURLTest#test_search:
NoMethodError: undefined method `filechanges' for nil:NilClass
plugins/full_text_search/test/functional/full_text_search/search_controller_test.rb:539:in `test_search'
rails test plugins/full_text_search/test/functional/full_text_search/search_controller_test.rb:537
......E
Error:
FullTextSearch::SearchControllerTest::ChangeSubURLTest#test_api:
NoMethodError: undefined method `filechanges' for nil:NilClass
plugins/full_text_search/test/functional/full_text_search/search_controller_test.rb:650:in `test_api'
rails test plugins/full_text_search/test/functional/full_text_search/search_controller_test.rb:648
E
Error:
FullTextSearch::SearchControllerTest::ChangeSubURLTest#test_search:
NoMethodError: undefined method `filechanges' for nil:NilClass
plugins/full_text_search/test/functional/full_text_search/search_controller_test.rb:633:in `test_search'
rails test plugins/full_text_search/test/functional/full_text_search/search_controller_test.rb:631
..................................E
Error:
FullTextSearch::ChangeSubversionTest#test_fetch_changesets:
ActiveRecord::RecordNotFound: Couldn't find Change
plugins/full_text_search/test/unit/full_text_search/change_subversion_test.rb:32:in `test_fetch_changesets'
rails test plugins/full_text_search/test/unit/full_text_search/change_subversion_test.rb:19
E
Error:
FullTextSearch::ChangeSubversionTest#test_fetch_changesets_sub_path:
NoMethodError: undefined method `each' for nil:NilClass
plugins/full_text_search/test/test_helper.rb:191:in `collect_files'
plugins/full_text_search/test/test_helper.rb:181:in `files'
plugins/full_text_search/test/unit/full_text_search/change_subversion_test.rb:73:in `test_fetch_changesets_sub_path'
rails test plugins/full_text_search/test/unit/full_text_search/change_subversion_test.rb:67
Capybara starting Puma...
* Version 6.4.0 , codename: The Eagle of Durango
* Min threads: 0, max threads: 4
* Listening on http://127.0.0.1:56807
...........
Finished in 126.665618s, 0.7579 runs/s, 0.9474 assertions/s.
96 runs, 120 assertions, 0 failures, 6 errors, 0 skips
Considering these results, I'm thinking about what I should do as a next action.
I just realized that the master branch uses Rails version 7.1.2 in Redmine. Although I tried to use the master branch and found there were other issues, I think we might deal with this one as a next action.
% git switch master
% bundle install
% plugins/full_text_search/dev/initialize-redmine.sh
+ test_svn_repository=tmp/test/subversion_repository
+ '[' '!' -d tmp/test/subversion_repository ']'
+ test_git_repository=tmp/test/git_repository
+ '[' '!' -d tmp/test/git_repository ']'
+ ruby bin/rails db:drop
bin/rails aborted!
NameError: uninitialized constant FullTextSearch (NameError)
FullTextSearch::Settings
^^^^^^^^^^
/Users/otegami/dev/project/redmine/plugins/full_text_search/init.rb:37:in `block in <top (required)>'
/Users/otegami/dev/project/redmine/plugins/full_text_search/init.rb:88:in `<top (required)>'
/Users/otegami/dev/project/redmine/lib/redmine/plugin_loader.rb:31:in `load'
/Users/otegami/dev/project/redmine/lib/redmine/plugin_loader.rb:31:in `run_initializer'
/Users/otegami/dev/project/redmine/lib/redmine/plugin_loader.rb:108:in `each'
/Users/otegami/dev/project/redmine/lib/redmine/plugin_loader.rb:108:in `block in load'
/Users/otegami/dev/project/redmine/config/environment.rb:16:in `<top (required)>'
Tasks: TOP => db:drop => db:load_config => environment
(See full trace by running task with --trace)
+ true
+ ruby bin/rails generate_secret_token
+ ruby bin/rails db:create
bin/rails aborted!
NameError: uninitialized constant FullTextSearch (NameError)
FullTextSearch::Settings
^^^^^^^^^^
/Users/otegami/dev/project/redmine/plugins/full_text_search/init.rb:37:in `block in <top (required)>'
/Users/otegami/dev/project/redmine/plugins/full_text_search/init.rb:88:in `<top (required)>'
/Users/otegami/dev/project/redmine/lib/redmine/plugin_loader.rb:31:in `load'
/Users/otegami/dev/project/redmine/lib/redmine/plugin_loader.rb:31:in `run_initializer'
/Users/otegami/dev/project/redmine/lib/redmine/plugin_loader.rb:108:in `each'
/Users/otegami/dev/project/redmine/lib/redmine/plugin_loader.rb:108:in `block in load'
/Users/otegami/dev/project/redmine/config/environment.rb:16:in `<top (required)>'
Tasks: TOP => db:create => db:load_config => environment
(See full trace by running task with --trace)
The latest version of Redmine is 5.1.1 and uses Rails version 6.1.7 judging from official web site. So I'm stuck about how I should deal with this point.
@kou Could you give me some advice about this issue?
Could you use redmine-5.0
for #115 for now?
We can use this issue to add support for Redmine 5.1.
FYI: We want to use structure.sql
instead of schema.rb
. We did it for Redmine < 5.1.
Could you use redmine-5.0 for https://github.com/clear-code/redmine_full_text_search/issues/115 for now?
I appreciate your help. Sure!
FYI: We want to use structure.sql instead of schema.rb. We did it for Redmine < 5.1.
I got it. Here is the commit.
@kou I want to take this issue. Could you help me to do it? we will have to do the following list for supporting Redmine5.1. Could you tell me if there are other tasks?
"Adding needed changes for Redmine 5.1" is missing. It's the most important task.
We have CI jobs with Redmine master. We can use them for "adding needed changes for Redmine 5.1 (master)" in the first step. Then we can add CI jobs for Redmine 5.1.
Thanks. I misunderstood the purpose of this issue. I will search for what we need to support Redmine master
.
I thought this issue wouldn't support Redmine master
but Redmine 5.1
because Rails version is different between 5.1 and master.
Redmine version | Related Rails | Link |
---|---|---|
master | v7.1.2 | https://github.com/redmine/redmine/blob/18cb44684b79d23dc1c45e4a9eeeb73dda5e9194/Gemfile#L5 |
v5.1.1 | v6.1.7 | https://github.com/redmine/redmine/blob/26f3a4192a72c8656581f161ead123fd5d050921/Gemfile#L5 |
I thought this issue wouldn't support
Redmine master
butRedmine 5.1
because Rails version is different between 5.1 and master.
Ah, Rails versions were same when I saw Redmine master and 5.1. OK. We can add support for Redmine 5.1 and then Redmine master.
Adding CI for Redmine master
We already have it. We don't have one for Redmine 5.1.
OK. We can add support for Redmine 5.1 and then Redmine master.
Sure!
Solved by #123.
I encountered an issue while setting up Redmine for development with PostgreSQL as the database. The error occurred when running the run-test.sh script as part of the full text search plugin setup.
Full error logs
```console % plugins/full_text_search/dev/run-test.sh (git)-[5.1-stable]- ++ grep '^gem '\''rails'\''' Gemfile ++ grep -o '[0-9]*' ++ head -n1 + rails_version_major=6 + '[' 6 -ge 6 ']' + env PSQLRC=/tmp/nonexistent RAILS_ENV=test ruby bin/rails test 'plugins/*/test/**/*_test.rb' PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from /Users/otegami/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activerecord-6.1.7.6/lib/active_record/connection_adapters/postgresql_adapter.rb:883:in `new' rails aborted! ActiveRecord::StatementInvalid: PG::UndefinedObject: ERROR: operator class "pgroonga_text_term_search_ops" does not exist for access method "pgroonga" (ActiveRecord::StatementInvalid) /Users/otegami/dev/project/redmine/db/schema.rb:219:in `block inHow to Reproduce
My environment
Steps
How to Develop
Expected Behavior
The run-test.sh script should execute without errors, allowing for the testing of the full text search plugin in a development environment.
Steps I tried to Resolve the Issue
bin/rails db:migrate:status RAILS_ENV=test
```console % bin/rails db:migrate:status RAILS_ENV=test (git)-[5.1-stable]- database: redmine_master_test Status Migration ID Migration Name -------------------------------------------------- down 001 Setup ... down 20231012112407 Remove mention users permission ```bin/rails db:migrate RAILS_ENV=test
```console % bin/rails db:migrate RAILS_ENV=test (git)-[5.1-stable]- == 1 Setup: migrating ========================================================= -- create_table("attachments", {:force=>true, :id=>:integer}) -> 0.0151s -- create_table("auth_sources", {:force=>true, :id=>:integer}) -> 0.0064s -- create_table("custom_fields", {:force=>true, :id=>:integer}) -> 0.0065s -- create_table("custom_fields_projects", {:id=>false, :force=>true}) -> 0.0016s -- create_table("custom_fields_trackers", {:id=>false, :force=>true}) -> 0.0016s -- create_table("custom_values", {:force=>true, :id=>:integer}) -> 0.0050s -- create_table("documents", {:force=>true, :id=>:integer}) -> 0.0053s -- add_index("documents", ["project_id"], {:name=>"documents_project_id"}) -> 0.0021s -- create_table("enumerations", {:force=>true, :id=>:integer}) -> 0.0036s -- create_table("issue_categories", {:force=>true, :id=>:integer}) -> 0.0032s -- add_index("issue_categories", ["project_id"], {:name=>"issue_categories_project_id"}) -> 0.0012s -- create_table("issue_histories", {:force=>true, :id=>:integer}) -> 0.0050s -- add_index("issue_histories", ["issue_id"], {:name=>"issue_histories_issue_id"}) -> 0.0018s -- create_table("issue_statuses", {:force=>true, :id=>:integer}) -> 0.0036s -- create_table("issues", {:force=>true, :id=>:integer}) -> 0.0050s -- add_index("issues", ["project_id"], {:name=>"issues_project_id"}) -> 0.0014s -- create_table("members", {:force=>true, :id=>:integer}) -> 0.0035s -- create_table("news", {:force=>true, :id=>:integer}) -> 0.0040s -- add_index("news", ["project_id"], {:name=>"news_project_id"}) -> 0.0012s -- create_table("permissions", {:force=>true, :id=>:integer}) -> 0.0035s -- create_table("permissions_roles", {:id=>false, :force=>true}) -> 0.0011s -- add_index("permissions_roles", ["role_id"], {:name=>"permissions_roles_role_id"}) -> 0.0011s -- create_table("projects", {:force=>true, :id=>:integer}) -> 0.0035s -- create_table("roles", {:force=>true, :id=>:integer}) -> 0.0016s -- create_table("tokens", {:force=>true, :id=>:integer}) -> 0.0036s -- create_table("trackers", {:force=>true, :id=>:integer}) -> 0.0022s -- create_table("users", {:force=>true, :id=>:integer}) -> 0.0035s -- create_table("versions", {:force=>true, :id=>:integer}) -> 0.0029s -- add_index("versions", ["project_id"], {:name=>"versions_project_id"}) -> 0.0009s -- create_table("workflows", {:force=>true, :id=>:integer}) -> 0.0024s == 1 Setup: migrated (0.1322s) ================================================ == 2 IssueMove: migrating ===================================================== == 2 IssueMove: migrated (0.0030s) ============================================ == 3 IssueAddNote: migrating ================================================== == 3 IssueAddNote: migrated (0.0027s) ========================================= == 4 ExportPdf: migrating ===================================================== == 4 ExportPdf: migrated (0.0030s) ============================================ == 5 IssueStartDate: migrating ================================================ -- add_column(:issues, :start_date, :date) -> 0.0007s -- add_column(:issues, :done_ratio, :integer, {:default=>0, :null=>false}) -> 0.0007s == 5 IssueStartDate: migrated (0.0015s) ======================================= == 6 CalendarAndActivity: migrating =========================================== == 6 CalendarAndActivity: migrated (0.0044s) ================================== == 7 CreateJournals: migrating ================================================ -- create_table(:journals, {:force=>true, :id=>:integer}) -> 0.0038s -- create_table(:journal_details, {:force=>true, :id=>:integer}) -> 0.0035s -- add_index("journals", ["journalized_id", "journalized_type"], {:name=>"journals_journalized_id"}) -> 0.0011s -- add_index("journal_details", ["journal_id"], {:name=>"journal_details_journal_id"}) -> 0.0012s -- drop_table(:issue_histories) -> 0.0009s == 7 CreateJournals: migrated (0.0141s) ======================================= == 8 CreateUserPreferences: migrating ========================================= -- create_table(:user_preferences, {:id=>:integer}) -> 0.0035s == 8 CreateUserPreferences: migrated (0.0035s) ================================ == 9 AddHideMailPref: migrating =============================================== -- add_column(:user_preferences, :hide_mail, :boolean, {:default=>false}) -> 0.0013s == 9 AddHideMailPref: migrated (0.0013s) ====================================== == 10 CreateComments: migrating =============================================== -- create_table(:comments, {:id=>:integer}) rails aborted! StandardError: An error has occurred, this and all later migrations canceled: (StandardError) PG::DuplicateTable: ERROR: relation "comments" already exists /Users/otegami/dev/project/redmine/db/migrate/010_create_comments.rb:3:in `up' Caused by: ActiveRecord::StatementInvalid: PG::DuplicateTable: ERROR: relation "comments" already exists (ActiveRecord::StatementInvalid) /Users/otegami/dev/project/redmine/db/migrate/010_create_comments.rb:3:in `up' Caused by: PG::DuplicateTable: ERROR: relation "comments" already exists (PG::DuplicateTable) /Users/otegami/dev/project/redmine/db/migrate/010_create_comments.rb:3:in `up' Tasks: TOP => db:migrate (See full trace by running task with --trace) ```bin/rails db:migrate:status RAILS_ENV=test
```console % bin/rails db:migrate:status RAILS_ENV=test (git)-[5.1-stable]- database: redmine_master_test Status Migration ID Migration Name -------------------------------------------------- up 001 Setup up 002 Issue move up 003 Issue add note up 004 Export pdf up 005 Issue start date up 006 Calendar and activity up 007 Create journals up 008 Create user preferences up 009 Add hide mail pref down 010 Create comments down 011 Add news comments count ... down 20231012112407 Remove mention users permission ```bin/rails db:environment:set RAILS_ENV=test && bin/rails db:drop db:create db:migrate RAILS_ENV=test
```console % bin/rails db:environment:set RAILS_ENV=test % bin/rails db:drop db:create db:migrate RAILS_ENV=test % % bin/rails db:migrate:status RAILS_ENV=test (git)-[5.1-stable]- database: redmine_master_test Status Migration ID Migration Name -------------------------------------------------- up 001 Setup ... up 20231012112407 Remove mention users permission ```plugins/full_text_search/dev/run-test.sh
```console % plugins/full_text_search/dev/run-test.sh .... E Error: FullTextSearch::CustomValueTest#test_save_project: ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "fts_types" does not exist LINE 8: WHERE a.attrelid = '"fts_types"'::regclass ^ plugins/full_text_search/app/models/full_text_search/type.rb:36:in `custom_value' plugins/full_text_search/app/models/full_text_search/type.rb:11:in `[]' plugins/full_text_search/lib/full_text_search/mapper.rb:110:in `fts_target_keys' plugins/full_text_search/lib/full_text_search/mapper.rb:94:in `find_fts_target' plugins/full_text_search/lib/full_text_search/custom_value_mapper.rb:38:in `upsert_fts_target' plugins/full_text_search/app/jobs/full_text_search/upsert_target_job.rb:12:in `perform' plugins/full_text_search/lib/full_text_search/mapper.rb:16:in `after_commit' plugins/full_text_search/test/unit/full_text_search/custom_value_test.rb:44:in `test_save_project' rails test plugins/full_text_search/test/unit/full_text_search/custom_value_test.rb:41 Finished in 8.539520s, 11.2418 runs/s, 1.6394 assertions/s. 96 runs, 14 assertions, 0 failures, 82 errors, 0 skips ```