From 3602d11a5b4d52b7ccbb093341931f51bd8a9ab6 Mon Sep 17 00:00:00 2001 From: glacials Date: Thu, 17 Oct 2024 09:49:41 -0700 Subject: [PATCH] Upgrade to Ruby 2.7.8 -> 3.0.7, Rails 6.0 -> 6.1 --- .rubocop.yml | 2 +- Gemfile | 16 +- Gemfile.lock | 295 ++++++++++-------- .../api/v4/application_controller.rb | 4 +- app/models/duration.rb | 3 + app/models/entry.rb | 2 +- app/models/run.rb | 2 +- app/models/segment_history.rb | 4 +- app/views/sessions/_sign_in.slim | 2 +- ..._two_factor_required_to_sessions.authie.rb | 8 + ...add_countries_to_authie_sessions.authie.rb | 10 + ..._to_active_storage_blobs.active_storage.rb | 22 ++ ..._storage_variant_records.active_storage.rb | 27 ++ db/schema.rb | 18 +- docker-compose-production.yml | 2 +- docker-compose.yml | 2 +- 16 files changed, 268 insertions(+), 151 deletions(-) create mode 100644 db/migrate/20241017164129_add_two_factor_required_to_sessions.authie.rb create mode 100644 db/migrate/20241017164130_add_countries_to_authie_sessions.authie.rb create mode 100644 db/migrate/20241017164529_add_service_name_to_active_storage_blobs.active_storage.rb create mode 100644 db/migrate/20241017164530_create_active_storage_variant_records.active_storage.rb diff --git a/.rubocop.yml b/.rubocop.yml index 80768d9c5..7af8c9f64 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,7 +3,7 @@ require: rubocop-rails Layout/LineLength: Max: 120 AllCops: - TargetRubyVersion: "2.7.8" # Also update docker-compose.yml, docker-compose-production.yml, and Gemfile + TargetRubyVersion: "3.0.7" # Also update docker-compose.yml, docker-compose-production.yml, and Gemfile Include: - "**/*.rb" - Rakefile diff --git a/Gemfile b/Gemfile index c0fc29d45..f039189b0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source "https://rubygems.org" -ruby "2.7.8" # also update docker-compose.yml & docker-compose-production.yml +ruby "3.0.7" # also update docker-compose.yml, docker-compose-production.yml, & .rubocop.yml git_source(:github) { |repo| "https://github.com/#{repo}.git" } @@ -19,6 +19,12 @@ group :test do end group :development, :hot do + # coding + gem "syntax_suggest" + + # filesystem + gem "listen" + # errors+logging gem "better_errors" gem "binding_of_caller" @@ -33,8 +39,6 @@ group :development, :hot do # views gem "rails_real_favicon" - - gem "listen" end group :production do @@ -84,7 +88,7 @@ gem "pg_search" gem "strong_migrations" # errors+logging -gem "newrelic_rpm" +gem "newrelic_rpm", "~> 6.12" gem "skylight", "~> 5.0.0.beta4" # external communication @@ -104,7 +108,9 @@ gem "rack-mini-profiler" # server/environment gem "ffi" gem "puma" -gem "rails", "~> 6.0" +gem "rails", "~> 6.1" +# see https://stackoverflow.com/questions/65617143/cannot-load-such-file-webrick-httputils +gem "webrick" # see https://github.com/faye/websocket-driver-ruby/issues/58#issuecomment-394611125 gem "websocket-driver", github: "faye/websocket-driver-ruby", ref: "ee39af83d03ae3059c775583e4c4b291641257b8" diff --git a/Gemfile.lock b/Gemfile.lock index 9077cfd36..f35c48e93 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -23,38 +23,40 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (6.0.3.1) - actionpack (= 6.0.3.1) + actioncable (6.1.7.9) + actionpack (= 6.1.7.9) + activesupport (= 6.1.7.9) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.0.3.1) - actionpack (= 6.0.3.1) - activejob (= 6.0.3.1) - activerecord (= 6.0.3.1) - activestorage (= 6.0.3.1) - activesupport (= 6.0.3.1) + actionmailbox (6.1.7.9) + actionpack (= 6.1.7.9) + activejob (= 6.1.7.9) + activerecord (= 6.1.7.9) + activestorage (= 6.1.7.9) + activesupport (= 6.1.7.9) mail (>= 2.7.1) - actionmailer (6.0.3.1) - actionpack (= 6.0.3.1) - actionview (= 6.0.3.1) - activejob (= 6.0.3.1) + actionmailer (6.1.7.9) + actionpack (= 6.1.7.9) + actionview (= 6.1.7.9) + activejob (= 6.1.7.9) + activesupport (= 6.1.7.9) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.0.3.1) - actionview (= 6.0.3.1) - activesupport (= 6.0.3.1) - rack (~> 2.0, >= 2.0.8) + actionpack (6.1.7.9) + actionview (= 6.1.7.9) + activesupport (= 6.1.7.9) + rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.0.3.1) - actionpack (= 6.0.3.1) - activerecord (= 6.0.3.1) - activestorage (= 6.0.3.1) - activesupport (= 6.0.3.1) + actiontext (6.1.7.9) + actionpack (= 6.1.7.9) + activerecord (= 6.1.7.9) + activestorage (= 6.1.7.9) + activesupport (= 6.1.7.9) nokogiri (>= 1.8.5) - actionview (6.0.3.1) - activesupport (= 6.0.3.1) + actionview (6.1.7.9) + activesupport (= 6.1.7.9) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -63,29 +65,31 @@ GEM activesupport (>= 5) active_record_union (1.3.0) activerecord (>= 4.0) - activejob (6.0.3.1) - activesupport (= 6.0.3.1) + activejob (6.1.7.9) + activesupport (= 6.1.7.9) globalid (>= 0.3.6) - activemodel (6.0.3.1) - activesupport (= 6.0.3.1) - activerecord (6.0.3.1) - activemodel (= 6.0.3.1) - activesupport (= 6.0.3.1) + activemodel (6.1.7.9) + activesupport (= 6.1.7.9) + activerecord (6.1.7.9) + activemodel (= 6.1.7.9) + activesupport (= 6.1.7.9) activerecord-import (1.0.5) activerecord (>= 3.2) activerecord-nulldb-adapter (0.4.0) activerecord (>= 2.0.0) - activestorage (6.0.3.1) - actionpack (= 6.0.3.1) - activejob (= 6.0.3.1) - activerecord (= 6.0.3.1) - marcel (~> 0.3.1) - activesupport (6.0.3.1) + activestorage (6.1.7.9) + actionpack (= 6.1.7.9) + activejob (= 6.1.7.9) + activerecord (= 6.1.7.9) + activesupport (= 6.1.7.9) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (6.1.7.9) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.2, >= 2.2.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) administrate (0.13.0) @@ -101,8 +105,8 @@ GEM selectize-rails (~> 0.6) api-pagination (4.8.2) ast (2.4.0) - authie (3.3.1) - secure_random_string + authie (4.1.1) + activerecord (>= 5.0, < 8.0) autoprefixer-rails (9.7.6) execjs aws-eventstream (1.1.0) @@ -127,63 +131,73 @@ GEM aws-sigv4 (~> 1.1) aws-sigv4 (1.1.4) aws-eventstream (~> 1.0, >= 1.0.2) + base64 (0.2.0) bcrypt (3.1.16) - benchmark-ips (2.8.2) + benchmark-ips (2.14.0) better_errors (2.8.0) coderay (>= 1.0.0) erubi (>= 1.0.0) rack (>= 0.9.0) - binding_of_caller (0.8.0) - debug_inspector (>= 0.0.1) + bigdecimal (3.1.8) + binding_of_caller (1.0.1) + debug_inspector (>= 1.2.0) blueprinter (0.23.4) - bootsnap (1.4.6) - msgpack (~> 1.0) + bootsnap (1.18.4) + msgpack (~> 1.2) bootstrap4-kaminari-views (1.0.1) kaminari (>= 0.13) rails (>= 3.1) - builder (3.2.4) + builder (3.3.0) byebug (11.1.3) cancancan (3.1.0) chartkick (3.4.0) choice (0.2.0) coderay (1.1.3) - concurrent-ruby (1.2.2) + concurrent-ruby (1.3.4) crass (1.0.6) daemons (1.3.1) dalli (2.7.10) + date (3.3.4) datetime_picker_rails (0.0.7) momentjs-rails (>= 2.8.1) - debug_inspector (0.0.3) - delayed_job (4.1.8) - activesupport (>= 3.0, < 6.1) - delayed_job_active_record (4.1.4) - activerecord (>= 3.0, < 6.1) + debug_inspector (1.2.0) + delayed_job (4.1.12) + activesupport (>= 3.0, < 8.0) + delayed_job_active_record (4.1.10) + activerecord (>= 3.0, < 8.0) delayed_job (>= 3.0, < 5) delayed_job_web (1.4.4) activerecord (> 3.0.0) delayed_job (> 2.0.3) rack-protection (>= 1.5.5) sinatra (>= 1.4.4) - derailed_benchmarks (1.7.0) + derailed_benchmarks (2.2.1) + base64 benchmark-ips (~> 2) - get_process_mem (~> 0) + bigdecimal + drb + get_process_mem heapy (~> 0) - memory_profiler (~> 0) - mini_histogram (~> 0) + logger + memory_profiler (>= 0, < 2) + mini_histogram (>= 0.3.0) + mutex_m + ostruct rack (>= 1) + rack-test rake (> 10, < 14) - ruby-statistics (>= 2.1) + ruby-statistics (>= 4.0.1) + ruby2_keywords thor (>= 0.19, < 2) - unicode_plot (>= 0.0.4, < 1.0.0) descriptive_statistics (2.5.1) diff-lcs (1.3) - docile (1.3.2) + docile (1.4.1) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) doorkeeper (5.6.6) railties (>= 5) - enumerable-statistics (2.0.1) - erubi (1.12.0) + drb (2.2.1) + erubi (1.13.0) et-orbi (1.2.4) tzinfo execjs (2.7.0) @@ -201,10 +215,11 @@ GEM fugit (1.4.1) et-orbi (~> 1.1, >= 1.1.8) raabro (~> 1.4) - get_process_mem (0.2.5) + get_process_mem (1.0.0) + bigdecimal (>= 2.0) ffi (~> 1.0) - globalid (0.4.2) - activesupport (>= 4.2.0) + globalid (1.2.1) + activesupport (>= 6.1) gon (6.4.0) actionpack (>= 3.0.20) i18n (>= 0.7) @@ -213,14 +228,15 @@ GEM groupdate (5.0.0) activesupport (>= 5) hashie (5.0.0) - heapy (0.1.4) + heapy (0.2.0) + thor http-accept (1.7.0) http-cookie (1.0.3) domain_name (~> 0.5) httparty (0.18.0) mime-types (~> 3.0) multi_xml (>= 0.5.2) - i18n (1.14.1) + i18n (1.14.6) concurrent-ruby (~> 1.0) image_processing (1.12.2) mini_magick (>= 4.9.5, < 5) @@ -251,42 +267,52 @@ GEM activerecord kaminari-core (= 1.2.1) kaminari-core (1.2.1) - listen (3.2.1) + listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.21.3) + logger (1.6.1) + loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) - mail (2.7.1) + mail (2.8.1) mini_mime (>= 0.1.1) - marcel (0.3.3) - mimemagic (~> 0.3.2) - memory_profiler (0.9.14) - method_source (1.0.0) + net-imap + net-pop + net-smtp + marcel (1.0.4) + memory_profiler (1.0.2) + method_source (1.1.0) mime-types (3.3.1) mime-types-data (~> 3.2015) mime-types-data (3.2020.0512) - mimemagic (0.3.10) - nokogiri (~> 1) - rake - mini_histogram (0.1.3) + mini_histogram (0.3.1) mini_magick (4.11.0) - mini_mime (1.0.2) - mini_portile2 (2.8.2) - minitest (5.18.0) + mini_mime (1.1.5) + mini_portile2 (2.8.7) + minitest (5.25.1) momentjs-rails (2.20.1) railties (>= 3.1) moving_average (0.1.1) - msgpack (1.3.3) + msgpack (1.7.3) multi_json (1.15.0) multi_xml (0.6.0) multipart-post (2.1.1) mustermann (3.0.0) ruby2_keywords (~> 0.0.1) + mutex_m (0.2.0) + net-imap (0.4.17) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.0) + net-protocol netrc (0.11.0) - newrelic_rpm (6.11.0.365) - nio4r (2.5.9) - nokogiri (1.15.2) + newrelic_rpm (6.15.0) + nio4r (2.7.3) + nokogiri (1.16.7) mini_portile2 (~> 2.8.2) racc (~> 1.4) oauth2 (1.4.4) @@ -308,6 +334,7 @@ GEM omniauth (~> 1.9) order_as_specified (1.6) activerecord (>= 5.0.0) + ostruct (0.6.0) parallel (1.19.1) parser (2.7.1.3) ast (~> 2.4.0) @@ -328,8 +355,8 @@ GEM puma (5.6.7) nio4r (~> 2.0) raabro (1.4.0) - racc (1.7.0) - rack (2.2.7) + racc (1.8.1) + rack (2.2.10) rack-cors (1.1.1) rack (>= 2.0.0) rack-mini-profiler (2.0.2) @@ -340,27 +367,28 @@ GEM rack rack-test (2.1.0) rack (>= 1.3) - rails (6.0.3.1) - actioncable (= 6.0.3.1) - actionmailbox (= 6.0.3.1) - actionmailer (= 6.0.3.1) - actionpack (= 6.0.3.1) - actiontext (= 6.0.3.1) - actionview (= 6.0.3.1) - activejob (= 6.0.3.1) - activemodel (= 6.0.3.1) - activerecord (= 6.0.3.1) - activestorage (= 6.0.3.1) - activesupport (= 6.0.3.1) - bundler (>= 1.3.0) - railties (= 6.0.3.1) + rails (6.1.7.9) + actioncable (= 6.1.7.9) + actionmailbox (= 6.1.7.9) + actionmailer (= 6.1.7.9) + actionpack (= 6.1.7.9) + actiontext (= 6.1.7.9) + actionview (= 6.1.7.9) + activejob (= 6.1.7.9) + activemodel (= 6.1.7.9) + activerecord (= 6.1.7.9) + activestorage (= 6.1.7.9) + activesupport (= 6.1.7.9) + bundler (>= 1.15.0) + railties (= 6.1.7.9) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.4) actionpack (>= 5.0.1.x) actionview (>= 5.0.1.x) activesupport (>= 5.0.1.x) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) rails-erd (1.6.0) activerecord (>= 4.2) @@ -374,16 +402,16 @@ GEM json (>= 1.7, < 3) rails rubyzip (~> 2) - railties (6.0.3.1) - actionpack (= 6.0.3.1) - activesupport (= 6.0.3.1) + railties (6.1.7.9) + actionpack (= 6.1.7.9) + activesupport (= 6.1.7.9) method_source - rake (>= 0.8.7) - thor (>= 0.20.3, < 2.0) + rake (>= 12.2) + thor (~> 1.0) rainbow (3.0.0) - rake (13.0.6) - rb-fsevent (0.10.4) - rb-inotify (0.10.1) + rake (13.2.1) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) ffi (~> 1.0) redis (4.1.4) regexp_parser (1.7.0) @@ -438,7 +466,7 @@ GEM ruby-graphviz (1.2.5) rexml ruby-progressbar (1.10.1) - ruby-statistics (2.1.2) + ruby-statistics (4.0.1) ruby-vips (2.1.4) ffi (~> 1.12) ruby2_keywords (0.0.5) @@ -453,13 +481,14 @@ GEM sprockets (> 3.0) sprockets-rails tilt - secure_random_string (1.0.0) selectize-rails (0.12.6) semantic_range (2.3.0) - simplecov (0.18.5) + simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) - simplecov-html (0.12.2) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.13.1) + simplecov_json_formatter (0.1.4) sinatra (3.0.6) mustermann (~> 3.0) rack (~> 2.2, >= 2.2.4) @@ -470,12 +499,12 @@ GEM slim (4.1.0) temple (>= 0.7.6, < 0.9) tilt (>= 2.0.6, < 2.1) - sprockets (4.0.2) + sprockets (4.2.1) concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.2.1) - actionpack (>= 4.0) - activesupport (>= 4.0) + rack (>= 2.2.4, < 4) + sprockets-rails (3.5.2) + actionpack (>= 6.1) + activesupport (>= 6.1) sprockets (>= 3.0.0) staccato (0.5.3) stripe (5.22.0) @@ -485,25 +514,25 @@ GEM stripe (>= 1.36.2) strong_migrations (0.6.8) activerecord (>= 5) + syntax_suggest (2.0.0) temple (0.8.2) - thor (1.2.2) - thread_safe (0.3.6) + thor (1.3.2) tilt (2.0.10) - tzinfo (1.2.11) - thread_safe (~> 0.1) + timeout (0.4.1) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) unf (0.1.4) unf_ext unf_ext (0.0.7.7) unicode-display_width (1.7.0) - unicode_plot (0.0.4) - enumerable-statistics (>= 2.0.1) webpacker (5.1.1) activesupport (>= 5.2) rack-proxy (>= 0.6.1) railties (>= 5.2) semantic_range (>= 2.3.0) + webrick (1.8.2) websocket-extensions (0.1.5) - zeitwerk (2.6.8) + zeitwerk (2.6.18) PLATFORMS ruby @@ -548,7 +577,7 @@ DEPENDENCIES listen memory_profiler moving_average - newrelic_rpm + newrelic_rpm (~> 6.12) oj omniauth omniauth-google-oauth2 @@ -564,7 +593,7 @@ DEPENDENCIES purecss-rails! rack-cors rack-mini-profiler - rails (~> 6.0) + rails (~> 6.1) rails-controller-testing rails-erd rails_real_favicon @@ -582,12 +611,14 @@ DEPENDENCIES staccato stripe-rails strong_migrations + syntax_suggest tzinfo-data webpacker (>= 4.0.x) + webrick websocket-driver! RUBY VERSION - ruby 2.7.8p225 + ruby 3.0.7p220 BUNDLED WITH - 2.2.15 + 2.2.33 diff --git a/app/controllers/api/v4/application_controller.rb b/app/controllers/api/v4/application_controller.rb index 350e6f27d..60cc01610 100644 --- a/app/controllers/api/v4/application_controller.rb +++ b/app/controllers/api/v4/application_controller.rb @@ -1,8 +1,6 @@ class Api::V4::ApplicationController < ActionController::Base include Rails::Pagination - skip_before_action :set_browser_id - skip_before_action :touch_auth_session before_action :read_only_mode, if: -> { ENV["READ_ONLY_MODE"] == "1" } before_action :track @@ -22,7 +20,7 @@ def read_only_mode render template: "pages/read_only_mode" end - private + protected # override authie's current_user methods for API, so we don't set or obey cookies attr_accessor :current_user diff --git a/app/models/duration.rb b/app/models/duration.rb index 69f4b7fd0..8c1a74b9b 100644 --- a/app/models/duration.rb +++ b/app/models/duration.rb @@ -9,6 +9,9 @@ def initialize(milliseconds) end @duration = ActiveSupport::Duration.build(milliseconds / 1000.0) + ActiveSupport::Duration::PARTS.each do |part| + @duration.parts[part] = 0 if @duration.parts[part].nil? + end end # format accepts a number of milliseconds and returns a time like "HH:MM:SS". If precise is true, it returns a time diff --git a/app/models/entry.rb b/app/models/entry.rb index 871127a48..f8b61b063 100644 --- a/app/models/entry.rb +++ b/app/models/entry.rb @@ -7,7 +7,7 @@ class Entry < ApplicationRecord # coentries can be called instead of entry.race.entries to avoid needing to join on races. It can also be used as a # join model to e.g. discover number of 1st/2nd/3rd places by user more cheaply as a Rails-friendly query. This # relation INCLUDES "myself", e.g. entry.coentries will include entry in returned values. - has_many :coentries, source: :entries, class_name: 'Entry', primary_key: 'race_id', foreign_key: 'race_id' + has_many :coentries, class_name: 'Entry', primary_key: 'race_id', foreign_key: 'race_id' validates_with EntryValidator # Validators are not called before destroy's, so manually hook and prevent if race is started diff --git a/app/models/run.rb b/app/models/run.rb index e798a9ba4..b8702f164 100644 --- a/app/models/run.rb +++ b/app/models/run.rb @@ -201,7 +201,7 @@ def segment_history_stats(timing) .without_statistically_invalid_histories_for_run(self, timing) .where(segment: {runs: {id: id}}) .where.not(Run.duration_type(timing) => [0, nil]) - .where('segments_segment_histories.segment_number = 0 OR (other_histories.attempt_number = segment_histories.attempt_number AND other_histories.segment_number = segments_segment_histories.segment_number - 1)') + .where('segment.segment_number = 0 OR (other_histories.attempt_number = segment_histories.attempt_number AND other_histories.segment_number = segment.segment_number - 1)') .group(:segment_id) .select(stats_select_query(timing)) diff --git a/app/models/segment_history.rb b/app/models/segment_history.rb index 8e8adce5c..abe2ff6d2 100644 --- a/app/models/segment_history.rb +++ b/app/models/segment_history.rb @@ -37,7 +37,7 @@ def self.without_statistically_invalid_histories_for_run(run, timing) OR segment_histories.realtime_duration_ms IS NULL)) ) AS other_histories ON other_histories.attempt_number = segment_histories.attempt_number - AND other_histories.segment_number = segments_segment_histories.segment_number - 1}.squish, run_id: run.id]) + AND other_histories.segment_number = segment.segment_number - 1}.squish, run_id: run.id]) when Run::GAME joins(SegmentHistory.sanitize_sql_array [%Q{ LEFT JOIN ( @@ -51,7 +51,7 @@ def self.without_statistically_invalid_histories_for_run(run, timing) OR segment_histories.gametime_duration_ms IS NULL)) ) AS other_histories ON other_histories.attempt_number = segment_histories.attempt_number - AND other_histories.segment_number = segments_segment_histories.segment_number - 1}.squish, run_id: run.id]) + AND other_histories.segment_number = segment.segment_number - 1}.squish, run_id: run.id]) else raise 'Unsupported timing' end diff --git a/app/views/sessions/_sign_in.slim b/app/views/sessions/_sign_in.slim index 8a4afa8fd..a2575799d 100644 --- a/app/views/sessions/_sign_in.slim +++ b/app/views/sessions/_sign_in.slim @@ -20,7 +20,7 @@ ' Sign up #signin-tabs-content.tab-content #signin-tab-content.tab-pane.show.active role='tabpanel' aria-labelledby='signin-tab' - = form_with(model: Authie::Session.new, scope: :session, url: sessions_path, local: true) do |f| + = form_with(model: nil, scope: :session, url: sessions_path, local: true) do |f| .form-group.mx-auto = f.text_field(:email, placeholder: 'Email', class: 'form-control') .form-group.mx-auto diff --git a/db/migrate/20241017164129_add_two_factor_required_to_sessions.authie.rb b/db/migrate/20241017164129_add_two_factor_required_to_sessions.authie.rb new file mode 100644 index 000000000..cf421bd59 --- /dev/null +++ b/db/migrate/20241017164129_add_two_factor_required_to_sessions.authie.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true +# This migration comes from authie (originally 20220502180100) + +class AddTwoFactorRequiredToSessions < ActiveRecord::Migration[6.1] + def change + add_column :authie_sessions, :skip_two_factor, :boolean, default: false + end +end diff --git a/db/migrate/20241017164130_add_countries_to_authie_sessions.authie.rb b/db/migrate/20241017164130_add_countries_to_authie_sessions.authie.rb new file mode 100644 index 000000000..758326770 --- /dev/null +++ b/db/migrate/20241017164130_add_countries_to_authie_sessions.authie.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true +# This migration comes from authie (originally 20230627165500) + +class AddCountriesToAuthieSessions < ActiveRecord::Migration[6.1] + def change + add_column :authie_sessions, :login_ip_country, :string + add_column :authie_sessions, :two_factored_ip_country, :string + add_column :authie_sessions, :last_activity_ip_country, :string + end +end diff --git a/db/migrate/20241017164529_add_service_name_to_active_storage_blobs.active_storage.rb b/db/migrate/20241017164529_add_service_name_to_active_storage_blobs.active_storage.rb new file mode 100644 index 000000000..a15c6ce8e --- /dev/null +++ b/db/migrate/20241017164529_add_service_name_to_active_storage_blobs.active_storage.rb @@ -0,0 +1,22 @@ +# This migration comes from active_storage (originally 20190112182829) +class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0] + def up + return unless table_exists?(:active_storage_blobs) + + unless column_exists?(:active_storage_blobs, :service_name) + add_column :active_storage_blobs, :service_name, :string + + if configured_service = ActiveStorage::Blob.service.name + ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) + end + + change_column :active_storage_blobs, :service_name, :string, null: false + end + end + + def down + return unless table_exists?(:active_storage_blobs) + + remove_column :active_storage_blobs, :service_name + end +end diff --git a/db/migrate/20241017164530_create_active_storage_variant_records.active_storage.rb b/db/migrate/20241017164530_create_active_storage_variant_records.active_storage.rb new file mode 100644 index 000000000..94ac83af0 --- /dev/null +++ b/db/migrate/20241017164530_create_active_storage_variant_records.active_storage.rb @@ -0,0 +1,27 @@ +# This migration comes from active_storage (originally 20191206030411) +class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0] + def change + return unless table_exists?(:active_storage_blobs) + + # Use Active Record's configured type for primary key + create_table :active_storage_variant_records, id: primary_key_type, if_not_exists: true do |t| + t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type + t.string :variation_digest, null: false + + t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end + + private + def primary_key_type + config = Rails.configuration.generators + config.options[config.orm][:primary_key_type] || :primary_key + end + + def blobs_primary_key_type + pkey_name = connection.primary_key(:active_storage_blobs) + pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name } + pkey_column.bigint? ? :bigint : pkey_column.type + end +end diff --git a/db/schema.rb b/db/schema.rb index 8e39e1049..85269d499 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2,15 +2,15 @@ # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # -# This file is the source Rails uses to define your schema when running `rails -# db:schema:load`. When creating a new database, `rails db:schema:load` tends to +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to # be faster and is potentially less error prone than running all of your # migrations from scratch. Old migrations may fail to apply correctly if those # migrations use external dependencies or application code. # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2020_11_23_024528) do +ActiveRecord::Schema.define(version: 2024_10_17_164530) do # These are extensions that must be enabled in order to support this database enable_extension "citext" @@ -36,9 +36,16 @@ t.bigint "byte_size", null: false t.string "checksum", null: false t.datetime "created_at", null: false + t.string "service_name", null: false t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true end + create_table "active_storage_variant_records", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.uuid "blob_id", null: false + t.string "variation_digest", null: false + t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true + end + create_table "authie_sessions", id: :serial, force: :cascade do |t| t.string "token" t.string "browser_id" @@ -62,6 +69,10 @@ t.datetime "password_seen_at" t.string "token_hash" t.string "host" + t.boolean "skip_two_factor", default: false + t.string "login_ip_country" + t.string "two_factored_ip_country" + t.string "last_activity_ip_country" t.index ["browser_id"], name: "index_authie_sessions_on_browser_id" t.index ["token"], name: "index_authie_sessions_on_token" t.index ["token_hash"], name: "index_authie_sessions_on_token_hash" @@ -541,6 +552,7 @@ end add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" + add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" add_foreign_key "chat_messages", "races" add_foreign_key "chat_messages", "users" add_foreign_key "entries", "races" diff --git a/docker-compose-production.yml b/docker-compose-production.yml index de57973bb..8c502f014 100644 --- a/docker-compose-production.yml +++ b/docker-compose-production.yml @@ -54,7 +54,7 @@ x-app: &app cache_from: - "${REPOSITORY_URI:-splitsio}:latest" args: - RUBY_VERSION: "2.7.8" # also update docker-compose.yml, Gemfile, and .rubocop.yml + RUBY_VERSION: "3.0.7" # also update docker-compose.yml, Gemfile, and .rubocop.yml environment: *server-environment image: splitsio logging: *default-logging diff --git a/docker-compose.yml b/docker-compose.yml index bbd68121d..3d3f1820b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -43,7 +43,7 @@ x-app: &app context: . dockerfile: Dockerfile args: - RUBY_VERSION: "2.7.8" # also update docker-compose-production.yml, Gemfile, and .rubocop.yml + RUBY_VERSION: "3.0.7" # also update docker-compose-production.yml, Gemfile, and .rubocop.yml image: splitsio tmpfs: - /tmp