From c8f58cc68794319062b34870a24858fec2f253df Mon Sep 17 00:00:00 2001 From: yuenmichelle1 Date: Fri, 27 Sep 2024 12:07:45 -0500 Subject: [PATCH 1/3] set up dual boot --- Gemfile | 4 +- Gemfile.next.lock | 117 ++++++++++++++++++------------------------ app/models/project.rb | 1 + app/models/user.rb | 1 + 4 files changed, 55 insertions(+), 68 deletions(-) diff --git a/Gemfile b/Gemfile index 2e8a30ab..5eb860c2 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ end source 'https://rubygems.org' if next? - gem 'rails', '5.1.7' + gem 'rails', '5.2.8.1' else gem 'rails', '5.1.7' end @@ -23,7 +23,7 @@ gem 'pundit', '~> 1.1.0' gem 'rack-cors', '~> 1.0.5' gem 'redis', '~> 3.3.0' gem 'restpack_serializer', git: 'https://github.com/zooniverse/restpack_serializer.git', branch: 'talk-api-version', ref: '637aaaf85e' -gem 'schema_plus_pg_indexes' +# gem 'schema_plus_pg_indexes' gem 'sidekiq', '< 6' gem 'sidekiq-congestion', '~> 0.1.0' gem 'sidekiq-cron' diff --git a/Gemfile.next.lock b/Gemfile.next.lock index 16f22aa6..ea8d00d2 100644 --- a/Gemfile.next.lock +++ b/Gemfile.next.lock @@ -12,46 +12,50 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (5.1.7) - actionpack (= 5.1.7) + actioncable (5.2.8.1) + actionpack (= 5.2.8.1) nio4r (~> 2.0) - websocket-driver (~> 0.6.1) - actionmailer (5.1.7) - actionpack (= 5.1.7) - actionview (= 5.1.7) - activejob (= 5.1.7) + websocket-driver (>= 0.6.1) + actionmailer (5.2.8.1) + actionpack (= 5.2.8.1) + actionview (= 5.2.8.1) + activejob (= 5.2.8.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.1.7) - actionview (= 5.1.7) - activesupport (= 5.1.7) - rack (~> 2.0) + actionpack (5.2.8.1) + actionview (= 5.2.8.1) + activesupport (= 5.2.8.1) + rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.1.7) - activesupport (= 5.1.7) + actionview (5.2.8.1) + activesupport (= 5.2.8.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.1.7) - activesupport (= 5.1.7) + activejob (5.2.8.1) + activesupport (= 5.2.8.1) globalid (>= 0.3.6) - activemodel (5.1.7) - activesupport (= 5.1.7) - activerecord (5.1.7) - activemodel (= 5.1.7) - activesupport (= 5.1.7) - arel (~> 8.0) - activesupport (5.1.7) + activemodel (5.2.8.1) + activesupport (= 5.2.8.1) + activerecord (5.2.8.1) + activemodel (= 5.2.8.1) + activesupport (= 5.2.8.1) + arel (>= 9.0) + activestorage (5.2.8.1) + actionpack (= 5.2.8.1) + activerecord (= 5.2.8.1) + marcel (~> 1.0.0) + activesupport (5.2.8.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) - arel (8.0.0) + arel (9.0.0) aws-sdk (2.3.23) aws-sdk-resources (= 2.3.23) aws-sdk-core (2.3.23) @@ -139,9 +143,8 @@ GEM http-accept (1.7.0) http-cookie (1.0.6) domain_name (~> 0.5) - i18n (1.14.5) + i18n (1.14.6) concurrent-ruby (~> 1.0) - its-it (1.3.0) jmespath (1.6.2) json (1.8.6) json-schema (2.8.1) @@ -161,7 +164,6 @@ GEM activerecord kaminari-core (= 1.2.2) kaminari-core (1.2.2) - key_struct (0.4.2) listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) @@ -180,17 +182,16 @@ GEM net-imap net-pop net-smtp + marcel (1.0.4) method_source (1.1.0) mime-types (3.5.2) mime-types-data (~> 3.2015) mime-types-data (3.2024.0806) mini_mime (1.1.5) mini_portile2 (2.8.7) - minitest (5.24.1) + minitest (5.25.1) mock_redis (0.36.0) ruby2_keywords - modware (0.1.3) - key_struct (~> 0.4) multipart-post (2.4.1) nenv (0.3.0) net-imap (0.3.7) @@ -230,17 +231,18 @@ GEM rack (~> 2.2, >= 2.2.4) rack-test (2.1.0) rack (>= 1.3) - rails (5.1.7) - actioncable (= 5.1.7) - actionmailer (= 5.1.7) - actionpack (= 5.1.7) - actionview (= 5.1.7) - activejob (= 5.1.7) - activemodel (= 5.1.7) - activerecord (= 5.1.7) - activesupport (= 5.1.7) + rails (5.2.8.1) + actioncable (= 5.2.8.1) + actionmailer (= 5.2.8.1) + actionpack (= 5.2.8.1) + actionview (= 5.2.8.1) + activejob (= 5.2.8.1) + activemodel (= 5.2.8.1) + activerecord (= 5.2.8.1) + activestorage (= 5.2.8.1) + activesupport (= 5.2.8.1) bundler (>= 1.3.0) - railties (= 5.1.7) + railties (= 5.2.8.1) sprockets-rails (>= 2.0.0) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) @@ -248,12 +250,12 @@ GEM nokogiri (>= 1.6) rails-html-sanitizer (1.5.0) loofah (~> 2.19, >= 2.19.1) - railties (5.1.7) - actionpack (= 5.1.7) - activesupport (= 5.1.7) + railties (5.2.8.1) + actionpack (= 5.2.8.1) + activesupport (= 5.2.8.1) method_source rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) + thor (>= 0.19.0, < 2.0) rake (13.2.1) rb-fsevent (0.11.2) rb-inotify (0.11.1) @@ -293,22 +295,6 @@ GEM rspec-support (~> 3.10) rspec-support (3.13.1) ruby2_keywords (0.0.5) - schema_monkey (2.1.6) - activerecord (>= 4.2) - modware (~> 0.1.0) - schema_plus_core (2.2.3) - activerecord (~> 5.0) - its-it (~> 1.2) - schema_monkey (~> 2.1) - schema_plus_indexes (0.3.1) - activerecord (>= 4.2, < 5.3) - its-it (~> 1.2) - schema_plus_core - schema_plus_pg_indexes (0.3.2) - activerecord (>= 5.0.1, < 5.3) - its-it (~> 1.2) - schema_plus_core (~> 2.0) - schema_plus_indexes (~> 0.2, >= 0.2.4) shellany (0.0.1) sidekiq (5.2.9) connection_pool (~> 2.2, >= 2.2.2) @@ -332,9 +318,9 @@ GEM sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) - sprockets-rails (3.2.2) - actionpack (>= 4.0) - activesupport (>= 4.0) + sprockets-rails (3.4.2) + actionpack (>= 5.2) + activesupport (>= 5.2) sprockets (>= 3.0.0) strscan (3.1.0) ten_years_rails (0.2.0) @@ -342,7 +328,7 @@ GEM activesupport colorize (>= 0.8.1) rest-client (>= 2.0.2) - thor (1.3.1) + thor (1.3.2) thread_safe (0.3.6) timecop (0.9.10) timeout (0.4.1) @@ -355,7 +341,7 @@ GEM addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - websocket-driver (0.6.5) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) zoo_stream (1.0.1) @@ -385,12 +371,11 @@ DEPENDENCIES puma pundit (~> 1.1.0) rack-cors (~> 1.0.5) - rails (= 5.1.7) + rails (= 5.2.8.1) redis (~> 3.3.0) restpack_serializer! rspec-its rspec-rails (~> 4.1.2) - schema_plus_pg_indexes sidekiq (< 6) sidekiq-congestion (~> 0.1.0) sidekiq-cron diff --git a/app/models/project.rb b/app/models/project.rb index 9556e7d5..8e6cbebc 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1,4 +1,5 @@ class Project < ApplicationRecord + self.primary_key = :id has_many :boards alias_attribute :title, :display_name diff --git a/app/models/user.rb b/app/models/user.rb index b3061c37..a8791424 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,4 +1,5 @@ class User < ApplicationRecord + self.primary_key = :id include Moderatable ALLOWED_LOGIN_CHARACTERS = '\w\-\.'.freeze From e8b35165542f03d052bb8dacd56b2811b5615d82 Mon Sep 17 00:00:00 2001 From: yuenmichelle1 Date: Mon, 21 Oct 2024 16:45:36 -0500 Subject: [PATCH 2/3] uncomment deprecated schema_plus_db_indexes will remove in another pr --- Gemfile | 2 +- Gemfile.next.lock | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index cd0f9044..8522b67b 100644 --- a/Gemfile +++ b/Gemfile @@ -23,7 +23,7 @@ gem 'pundit', '~> 1.1.0' gem 'rack-cors', '~> 1.0.5' gem 'redis', '~> 3.3.0' gem 'restpack_serializer', git: 'https://github.com/zooniverse/restpack_serializer.git', branch: 'talk-api-version', ref: '637aaaf85e' -# gem 'schema_plus_pg_indexes' +gem 'schema_plus_pg_indexes' gem 'sidekiq', '< 6' gem 'sidekiq-congestion', '~> 0.1.0' gem 'sidekiq-cron' diff --git a/Gemfile.next.lock b/Gemfile.next.lock index 0a2b9a77..13676393 100644 --- a/Gemfile.next.lock +++ b/Gemfile.next.lock @@ -145,6 +145,7 @@ GEM domain_name (~> 0.5) i18n (1.14.6) concurrent-ruby (~> 1.0) + its-it (1.3.0) jmespath (1.6.2) json (1.8.6) json-schema (2.8.1) @@ -164,6 +165,7 @@ GEM activerecord kaminari-core (= 1.2.2) kaminari-core (1.2.2) + key_struct (0.4.2) listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) @@ -192,6 +194,8 @@ GEM minitest (5.25.1) mock_redis (0.36.0) ruby2_keywords + modware (0.1.3) + key_struct (~> 0.4) multipart-post (2.4.1) nenv (0.3.0) net-imap (0.3.7) @@ -295,6 +299,22 @@ GEM rspec-support (~> 3.10) rspec-support (3.13.1) ruby2_keywords (0.0.5) + schema_monkey (2.1.6) + activerecord (>= 4.2) + modware (~> 0.1.0) + schema_plus_core (2.2.3) + activerecord (~> 5.0) + its-it (~> 1.2) + schema_monkey (~> 2.1) + schema_plus_indexes (0.3.1) + activerecord (>= 4.2, < 5.3) + its-it (~> 1.2) + schema_plus_core + schema_plus_pg_indexes (0.3.2) + activerecord (>= 5.0.1, < 5.3) + its-it (~> 1.2) + schema_plus_core (~> 2.0) + schema_plus_indexes (~> 0.2, >= 0.2.4) shellany (0.0.1) sidekiq (5.2.9) connection_pool (~> 2.2, >= 2.2.2) @@ -376,6 +396,7 @@ DEPENDENCIES restpack_serializer! rspec-its rspec-rails (~> 4.1.2) + schema_plus_pg_indexes sidekiq (< 6) sidekiq-congestion (~> 0.1.0) sidekiq-cron From b44f92bc508c5c15339f36db656c331e94ffd932 Mon Sep 17 00:00:00 2001 From: yuenmichelle1 Date: Tue, 22 Oct 2024 10:55:37 -0500 Subject: [PATCH 3/3] update rake task to accomodate rails 5.1 to 5.2 change of db:load_config sending new prereqs CI test workflows and local dev setup requires db:create rake task. However in Rails 5.2, there was an introduction of new behavior of db:load_config (a task within db:create) which causes db:create to fail. (This is a known issue from Rails and behavior introduced after 5.1.7). To fix, we delete the new environment prerequisite of db:load_config, (db:load_config depending on environment means the app would load with all observers, sphinx indices, concerns etc which trigger a db connection, BUT can't be established because the DB does not exist yet.). However, just removing the prerequisite, will get db:create to work, but loading schema will stop working because db:load_config needs that prereq and tehrefore we bring it back after db:create, knowing we have a db to connect to. --- Gemfile.next.lock | 53 +++++++++++++------------------------------ Rakefile | 24 ++++++++++++++++++++ app/models/subject.rb | 1 + 3 files changed, 41 insertions(+), 37 deletions(-) diff --git a/Gemfile.next.lock b/Gemfile.next.lock index 13676393..19282339 100644 --- a/Gemfile.next.lock +++ b/Gemfile.next.lock @@ -63,13 +63,12 @@ GEM aws-sdk-resources (2.3.23) aws-sdk-core (= 2.3.23) base64 (0.2.0) - benchmark-ips (2.13.0) + benchmark-ips (2.14.0) bigdecimal (3.1.8) builder (3.3.0) codeclimate-test-reporter (0.6.0) simplecov (>= 0.7.1, < 1.0.0) coderay (1.1.3) - colorize (1.1.0) concurrent-ruby (1.3.4) congestion (0.1.0) connection_pool (>= 2.0) @@ -82,8 +81,6 @@ GEM date (3.3.4) diff-lcs (1.5.1) docile (1.1.5) - domain_name (0.5.20190701) - unf (>= 0.0.5, < 1.0.0) erubi (1.13.0) et-orbi (1.2.11) tzinfo @@ -92,7 +89,7 @@ GEM factory_bot_rails (5.2.0) factory_bot (~> 5.2.0) railties (>= 4.2.0) - faraday (1.10.3) + faraday (1.10.4) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) faraday-excon (~> 1.1) @@ -115,11 +112,11 @@ GEM faraday-patron (1.0.0) faraday-rack (1.0.0) faraday-retry (1.0.3) - faraday_middleware (1.2.0) + faraday_middleware (1.2.1) faraday (~> 1.0) ffi (1.16.3) formatador (1.1.0) - fugit (1.11.0) + fugit (1.11.1) et-orbi (~> 1, >= 1.2.11) raabro (~> 1.4) globalid (1.1.0) @@ -140,9 +137,6 @@ GEM rspec (>= 2.99.0, < 4.0) hashdiff (1.1.1) honeybadger (4.5.6) - http-accept (1.7.0) - http-cookie (1.0.6) - domain_name (~> 0.5) i18n (1.14.6) concurrent-ruby (~> 1.0) its-it (1.3.0) @@ -186,9 +180,6 @@ GEM net-smtp marcel (1.0.4) method_source (1.1.0) - mime-types (3.5.2) - mime-types-data (~> 3.2015) - mime-types-data (3.2024.0806) mini_mime (1.1.5) mini_portile2 (2.8.7) minitest (5.25.1) @@ -207,8 +198,7 @@ GEM timeout net-smtp (0.5.0) net-protocol - netrc (0.11.0) - newrelic_rpm (9.12.0) + newrelic_rpm (9.14.0) nio4r (2.7.3) nokogiri (1.13.10) mini_portile2 (~> 2.8.0) @@ -221,13 +211,13 @@ GEM coderay (~> 1.1) method_source (~> 1.0) public_suffix (5.1.1) - puma (6.4.2) + puma (6.4.3) nio4r (~> 2.0) pundit (1.1.0) activesupport (>= 3.0.0) raabro (1.4.0) racc (1.8.1) - rack (2.2.9) + rack (2.2.10) rack-cors (1.0.6) rack (>= 1.6.0) rack-protection (3.2.0) @@ -260,6 +250,7 @@ GEM method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) + rainbow (3.0.0) rake (13.2.1) rb-fsevent (0.11.2) rb-inotify (0.11.1) @@ -267,26 +258,20 @@ GEM redis (3.3.5) request_store (1.7.0) rack (>= 1.4) - rest-client (2.1.0) - http-accept (>= 1.7.0, < 2.0) - http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 4.0) - netrc (~> 0.8) - rexml (3.3.5) - strscan + rexml (3.3.8) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) - rspec-core (3.13.0) + rspec-core (3.13.2) rspec-support (~> 3.13.0) - rspec-expectations (3.13.1) + rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-its (1.3.0) rspec-core (>= 3.0.0) rspec-expectations (>= 3.0.0) - rspec-mocks (3.13.1) + rspec-mocks (3.13.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-rails (4.1.2) @@ -342,22 +327,16 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - strscan (3.1.0) - ten_years_rails (0.2.0) - actionview - activesupport - colorize (>= 0.8.1) - rest-client (>= 2.0.2) + ten_years_rails (1.0.2) + actionview (~> 5.2.3) + rainbow (~> 3.0.0) thor (1.3.2) thread_safe (0.3.6) timecop (0.9.10) timeout (0.4.1) tzinfo (1.2.11) thread_safe (~> 0.1) - unf (0.1.4) - unf_ext - unf_ext (0.0.9.1) - webmock (3.23.1) + webmock (3.24.0) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) diff --git a/Rakefile b/Rakefile index 77bfffc7..00c4e645 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,27 @@ require File.expand_path('../config/application', __FILE__) Rails.application.load_tasks + +# In Rails 5.2 the `load_config` task was made dependent on `environment` +# to enable credentials reading, see https://github.com/rails/rails/pull/31135 +# This causes the whole app to initialize before `db:create` and that +# causes a database connection for observers, sphinx, concerns, etc, that cant be established +# when DB does not exist yet. +# See SO: https://stackoverflow.com/questions/72147515/rails-5-2-load-order-breaks-dbcreate +# While clearing the environment prerequisite of load_config will help db:create +# and create the db, other tasks like db:schema:load and our panoptes talk rake tasks +# will actually need the prereq, and therefore we bring back the environment prereq +# for other rake tasks. We do this to keep our CI test workflows and local dev environment setup functional. + +Rake::Task['db:load_config'].prerequisites.delete("environment") +Rake::Task.tasks.select { |task| + next if task.name == "db:create" + task.name.start_with?("db:") && task.prerequisites.include?("load_config") +}.each { |task| + task.prerequisites.insert(task.prerequisites.index("load_config"), "environment") +} +Rake::Task.tasks.select { |task| + task.prerequisites.include?("db:load_config") +}.each { |task| + task.prerequisites.insert(task.prerequisites.index("db:load_config"), "environment") +} \ No newline at end of file diff --git a/app/models/subject.rb b/app/models/subject.rb index 8b26f1ce..c8da9ccc 100644 --- a/app/models/subject.rb +++ b/app/models/subject.rb @@ -1,4 +1,5 @@ class Subject < ApplicationRecord + self.primary_key = :id include Focusable belongs_to :project end