diff --git a/.gitignore b/.gitignore index e0d233c0..281eff28 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ !/log/.keep /tmp solr +.DS_Store diff --git a/.ruby-version b/.ruby-version index ecd7ee50..a603bb50 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.5.8 +2.7.5 diff --git a/Dockerfile b/Dockerfile index f9ae6c55..7d661fbc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,10 @@ -FROM ruby:2.5.8 +FROM ruby:2.7.5 ARG git_sha ENV LANG C.UTF-8 RUN apt-get update \ && apt-get install --no-install-recommends -y libpq-dev postgresql-client sqlite3 libsqlite3-dev libssl-dev nodejs \ && rm -rf /var/lib/apt/lists/* -RUN gem install bundler -v '< 2' \ - && bundle config --global frozen 1 \ +RUN bundle config --global frozen 1 \ && bundle config github.https true \ && bundle config set deployment 'true' COPY Gemfile Gemfile.lock .ruby-version /app/ diff --git a/Gemfile b/Gemfile index 19e1dc61..664347af 100644 --- a/Gemfile +++ b/Gemfile @@ -3,10 +3,9 @@ source 'https://rubygems.org' # Fixing deprecated 'last_comment' method in newer versions of rake gem 'rake', '< 11.0' -gem 'calagator', git: 'https://github.com/calagator/calagator.git' +gem 'calagator', '2.0.0.pre.1' -# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '4.2.11' +gem 'rails', '~> 5.2' gem 'rails_12factor', group: :production @@ -38,6 +37,8 @@ gem 'progress_bar' gem "recaptcha", require: "recaptcha/rails" +gem 'paper_trail_manager', github: 'fusion94/paper_trail_manager', ref: 'b8630cd0e3318ad0929b80a701a18175402a4944' + # Performance and error monitoring gem 'airbrake' gem 'newrelic_rpm' diff --git a/Gemfile.lock b/Gemfile.lock index a60478f2..ca965edc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,126 +1,145 @@ GIT - remote: https://github.com/calagator/calagator.git - revision: 143d916a1bf5fb652def420e7c030a3512c85adc + remote: https://github.com/fusion94/paper_trail_manager.git + revision: b8630cd0e3318ad0929b80a701a18175402a4944 + ref: b8630cd0e3318ad0929b80a701a18175402a4944 specs: - calagator (1.1.0) - acts-as-taggable-on (~> 5.0) + paper_trail_manager (0.7.0) + paper_trail (>= 3.0) + rails (>= 3.0, < 7.0) + +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.6) + actionpack (= 5.2.6) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.6) + actionpack (= 5.2.6) + actionview (= 5.2.6) + activejob (= 5.2.6) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.6) + actionview (= 5.2.6) + activesupport (= 5.2.6) + 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.2.6) + activesupport (= 5.2.6) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.6) + activesupport (= 5.2.6) + globalid (>= 0.3.6) + activemodel (5.2.6) + activesupport (= 5.2.6) + activemodel-serializers-xml (1.0.2) + activemodel (> 5.x) + activesupport (> 5.x) + builder (~> 3.1) + activerecord (5.2.6) + activemodel (= 5.2.6) + activesupport (= 5.2.6) + arel (>= 9.0) + activestorage (5.2.6) + actionpack (= 5.2.6) + activerecord (= 5.2.6) + marcel (~> 1.0.0) + activesupport (5.2.6) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + acts-as-taggable-on (8.1.0) + activerecord (>= 5.0, < 6.2) + airbrake (12.0.0) + airbrake-ruby (~> 6.0) + airbrake-ruby (6.0.1) + rbtree3 (~> 0.5) + annotate (3.1.1) + activerecord (>= 3.2, < 7.0) + rake (>= 10.4, < 14.0) + arel (9.0.0) + binding_of_caller (1.0.0) + debug_inspector (>= 0.0.1) + bluecloth (2.2.0) + builder (3.2.4) + byebug (11.1.3) + calagator (2.0.0.pre.1) + activemodel-serializers-xml (~> 1.0) + acts-as-taggable-on (~> 8.1) + annotate (~> 3.1.1) bluecloth (~> 2.2) - font-awesome-rails (~> 4.3) - formtastic (~> 3.1) + font-awesome-rails (~> 4.7) + formtastic (~> 4.0) geokit (>= 1.9, < 1.14) htmlentities (~> 4.3) - jquery-rails - jquery-ui-rails (~> 5.0) + jquery-rails (~> 4.4) + jquery-ui-rails (~> 6.0) loofah (~> 2.0) loofah-activerecord (>= 1.2, < 3.0) lucene_query (= 0.1) microformats (>= 4.0.7, < 4.3.0) nokogiri - paper_trail_manager (~> 0.5.0) - rack-contrib (>= 1, < 3) - rails (~> 4.2) + rack-contrib (~> 2.3) + rails (~> 5.2) rails-observers rails_autolink (~> 1.1) - recaptcha (>= 5.3, < 5.5) + recaptcha (~> 5.8) rest-client (~> 2.0) ri_cal (~> 0.8.8) - sassc-rails (>= 1.3, < 3.0) + sassc-rails (~> 2.1) sunspot_rails (~> 2.1) utf8-cleaner (>= 0.0.6, < 1.1.0) - validate_url (~> 1.0) + validate_url will_paginate (~> 3.0) - -GEM - remote: https://rubygems.org/ - specs: - actionmailer (4.2.11) - actionpack (= 4.2.11) - actionview (= 4.2.11) - activejob (= 4.2.11) - mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.11) - actionview (= 4.2.11) - activesupport (= 4.2.11) - rack (~> 1.6) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.11) - activesupport (= 4.2.11) - builder (~> 3.1) - erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (4.2.11) - activesupport (= 4.2.11) - globalid (>= 0.3.0) - activemodel (4.2.11) - activesupport (= 4.2.11) - builder (~> 3.1) - activerecord (4.2.11) - activemodel (= 4.2.11) - activesupport (= 4.2.11) - arel (~> 6.0) - activesupport (4.2.11) - i18n (~> 0.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) - acts-as-taggable-on (5.0.0) - activerecord (>= 4.2.8) - airbrake (4.2.1) - builder - multi_json - arel (6.0.4) - binding_of_caller (0.7.2) - debug_inspector (>= 0.0.1) - bluecloth (2.2.0) - builder (3.2.4) - byebug (5.0.0) - columnize (= 0.9.0) - columnize (0.9.0) - concurrent-ruby (1.1.8) + concurrent-ruby (1.1.9) crass (1.0.6) - debug_inspector (0.0.2) - diff-lcs (1.2.5) + debug_inspector (1.1.0) + diff-lcs (1.4.4) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) - erubis (2.7.0) - execjs (2.7.0) - faraday (1.0.1) - multipart-post (>= 1.2, < 3) - ffi (1.12.2) - font-awesome-rails (4.7.0.5) - railties (>= 3.2, < 6.1) - formtastic (3.1.5) - actionpack (>= 3.2.13) + erubi (1.10.0) + execjs (2.8.1) + faraday (2.2.0) + faraday-net_http (~> 2.0) + ruby2_keywords (>= 0.0.4) + faraday-net_http (2.0.1) + ffi (1.15.4) + font-awesome-rails (4.7.0.8) + railties (>= 3.2, < 8.0) + formtastic (4.0.0) + actionpack (>= 5.2.0) geokit (1.13.1) - globalid (0.4.2) - activesupport (>= 4.2.0) - highline (1.6.21) + globalid (1.0.0) + activesupport (>= 5.0) + highline (2.0.3) htmlentities (4.3.4) http-accept (1.7.0) - http-cookie (1.0.3) + http-cookie (1.0.4) domain_name (~> 0.5) - i18n (0.9.5) + i18n (1.8.11) concurrent-ruby (~> 1.0) - jbuilder (2.2.16) - activesupport (>= 3.0.0, < 5) - multi_json (~> 1.2) - jquery-rails (4.3.5) + jbuilder (2.11.2) + activesupport (>= 5.0.0) + jquery-rails (4.4.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - jquery-ui-rails (5.0.5) + jquery-ui-rails (6.0.1) railties (>= 3.2.16) - json (2.3.0) + json (2.6.1) lograge (0.11.2) actionpack (>= 4) activesupport (>= 4) railties (>= 4) request_store (~> 1.0) - loofah (2.5.0) + loofah (2.13.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) loofah-activerecord (2.0.0) @@ -128,59 +147,58 @@ GEM lucene_query (0.1) mail (2.7.1) mini_mime (>= 0.1.1) - microformats (4.2.0) + marcel (1.0.2) + method_source (1.0.0) + microformats (4.2.1) json (~> 2.2) nokogiri (~> 1.10) - mime-types (3.3.1) + mime-types (3.4.1) mime-types-data (~> 3.2015) - mime-types-data (3.2020.0425) - mini_mime (1.0.2) - mini_portile2 (2.4.0) - minitest (5.14.0) - multi_json (1.14.1) - multipart-post (2.1.1) + mime-types-data (3.2022.0105) + mini_mime (1.1.2) + mini_portile2 (2.6.1) + minitest (5.15.0) + multi_json (1.15.0) netrc (0.11.0) - newrelic_rpm (6.9.0.363) - nio4r (2.5.7) - nokogiri (1.10.9) - mini_portile2 (~> 2.4.0) + newrelic_rpm (8.1.0) + nio4r (2.5.8) + nokogiri (1.12.5) + mini_portile2 (~> 2.6.1) + racc (~> 1.4) options (2.3.2) - paper_trail (3.0.9) - activerecord (>= 3.0, < 5.0) - activesupport (>= 3.0, < 5.0) - paper_trail_manager (0.5.0) - paper_trail (~> 3.0) - rails (>= 3.0, < 5.0) + paper_trail (12.1.0) + activerecord (>= 5.2) + request_store (~> 1.1) pr_geohash (1.0.0) - progress_bar (1.0.0) - highline (~> 1.6.1) + progress_bar (1.3.3) + highline (>= 1.6, < 3) options (~> 2.3.0) - public_suffix (4.0.4) - puma (5.2.2) + public_suffix (4.0.6) + puma (5.5.2) nio4r (~> 2.0) - rack (1.6.13) - rack-contrib (1.8.0) - rack (~> 1.4) - rack-test (0.6.3) - rack (>= 1.0) - rails (4.2.11) - actionmailer (= 4.2.11) - actionpack (= 4.2.11) - actionview (= 4.2.11) - activejob (= 4.2.11) - activemodel (= 4.2.11) - activerecord (= 4.2.11) - activesupport (= 4.2.11) - bundler (>= 1.3.0, < 2.0) - railties (= 4.2.11) - sprockets-rails - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.9) - activesupport (>= 4.2.0, < 5.0) - nokogiri (~> 1.6) - rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.3.0) + racc (1.6.0) + rack (2.2.3) + rack-contrib (2.3.0) + rack (~> 2.0) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.6) + actioncable (= 5.2.6) + actionmailer (= 5.2.6) + actionpack (= 5.2.6) + actionview (= 5.2.6) + activejob (= 5.2.6) + activemodel (= 5.2.6) + activerecord (= 5.2.6) + activestorage (= 5.2.6) + activesupport (= 5.2.6) + bundler (>= 1.3.0) + railties (= 5.2.6) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.4.2) loofah (~> 2.3) rails-observers (0.1.5) activemodel (>= 4.0) @@ -191,17 +209,19 @@ GEM rails (> 3.1) rails_serve_static_assets (0.0.5) rails_stdout_logging (0.0.5) - railties (4.2.11) - actionpack (= 4.2.11) - activesupport (= 4.2.11) + railties (5.2.6) + actionpack (= 5.2.6) + activesupport (= 5.2.6) + method_source rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) + thor (>= 0.19.0, < 2.0) rake (10.5.0) - rb-fsevent (0.10.3) + rb-fsevent (0.11.0) rb-inotify (0.10.1) ffi (~> 1.0) - rdoc (6.2.1) - recaptcha (5.4.1) + rbtree3 (0.6.0) + rdoc (6.3.2) + recaptcha (5.8.1) json request_store (1.5.0) rack (>= 1.4) @@ -211,38 +231,39 @@ GEM mime-types (>= 1.16, < 4.0) netrc (~> 0.8) ri_cal (0.8.8) - rsolr (2.3.0) + rsolr (2.5.0) builder (>= 2.1.2) - faraday (>= 0.9.0) - rspec-core (3.2.3) - rspec-support (~> 3.2.0) - rspec-expectations (3.2.1) + faraday (>= 0.9, < 3, != 2.0.0) + rspec-core (3.9.3) + rspec-support (~> 3.9.3) + rspec-expectations (3.9.4) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.2.0) - rspec-mocks (3.2.1) + rspec-support (~> 3.9.0) + rspec-mocks (3.9.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.2.0) - rspec-rails (3.2.1) - actionpack (>= 3.0, < 4.3) - activesupport (>= 3.0, < 4.3) - railties (>= 3.0, < 4.3) - rspec-core (~> 3.2.0) - rspec-expectations (~> 3.2.0) - rspec-mocks (~> 3.2.0) - rspec-support (~> 3.2.0) - rspec-support (3.2.2) + rspec-support (~> 3.9.0) + rspec-rails (3.9.1) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 3.9.0) + rspec-expectations (~> 3.9.0) + rspec-mocks (~> 3.9.0) + rspec-support (~> 3.9.0) + rspec-support (3.9.4) + ruby2_keywords (0.0.5) sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (5.0.7) - railties (>= 4.0.0, < 6) + sass-rails (5.1.0) + railties (>= 5.2.0) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - sassc (2.3.0) + sassc (2.4.0) ffi (~> 1.9) sassc-rails (2.1.2) railties (>= 4.0.0) @@ -252,43 +273,46 @@ GEM tilt sdoc (1.1.0) rdoc (>= 5.0) - spring (1.3.6) + spring (3.0.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.1) - actionpack (>= 4.0) - activesupport (>= 4.0) + sprockets-rails (3.4.2) + actionpack (>= 5.2) + activesupport (>= 5.2) sprockets (>= 3.0.0) - sqlite3 (1.3.10) + sqlite3 (1.4.2) sunspot (2.5.0) pr_geohash (~> 1.0) rsolr (>= 1.1.1, < 3) sunspot_rails (2.5.0) rails (>= 3) sunspot (= 2.5.0) - thor (1.0.1) + thor (1.1.0) thread_safe (0.3.6) tilt (2.0.10) - tzinfo (1.2.7) + tzinfo (1.2.9) thread_safe (~> 0.1) uglifier (1.3.0) execjs (>= 0.3.0) multi_json (~> 1.0, >= 1.0.2) unf (0.1.4) unf_ext - unf_ext (0.0.7.7) + unf_ext (0.0.8.1) utf8-cleaner (1.0.0) activesupport - validate_url (1.0.8) + validate_url (1.0.13) activemodel (>= 3.0.0) public_suffix - web-console (2.1.2) + web-console (2.3.0) activemodel (>= 4.0) binding_of_caller (>= 0.7.2) railties (>= 4.0) sprockets-rails (>= 2.0, < 4.0) - will_paginate (3.3.0) + websocket-driver (0.7.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + will_paginate (3.3.1) PLATFORMS ruby @@ -296,14 +320,15 @@ PLATFORMS DEPENDENCIES airbrake byebug - calagator! + calagator (= 2.0.0.pre.1) jbuilder (~> 2.0) jquery-rails lograge newrelic_rpm + paper_trail_manager! progress_bar puma - rails (= 4.2.11) + rails (~> 5.2) rails_12factor rake (< 11.0) recaptcha @@ -316,4 +341,4 @@ DEPENDENCIES web-console (~> 2.0) BUNDLED WITH - 1.17.3 + 2.1.4 diff --git a/app/assets/images/site-icon.png b/app/assets/images/site-icon.png new file mode 100644 index 00000000..674aad91 Binary files /dev/null and b/app/assets/images/site-icon.png differ diff --git a/app/assets/images/spinner.gif b/app/assets/images/spinner.gif new file mode 100644 index 00000000..43bc3970 Binary files /dev/null and b/app/assets/images/spinner.gif differ diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index f9f97465..245d676b 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -38,3 +38,4 @@ font-size: 70%; } } +//= require calagator \ No newline at end of file diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 00000000..10a4cba8 --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/bin/bundle b/bin/bundle index 524dfd3f..a71368e3 100755 --- a/bin/bundle +++ b/bin/bundle @@ -11,7 +11,7 @@ require "rubygems" m = Module.new do - module_function + module_function def invoked_as_script? File.expand_path($0) == File.expand_path(__FILE__) @@ -31,7 +31,7 @@ m = Module.new do bundler_version = a end next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ - bundler_version = $1 || ">= 0.a" + bundler_version = $1 update_index = i end bundler_version @@ -61,32 +61,41 @@ m = Module.new do end def bundler_version - @bundler_version ||= begin + @bundler_version ||= env_var_version || cli_arg_version || - lockfile_version || "#{Gem::Requirement.default}.a" - end + lockfile_version + end + + def bundler_requirement + return "#{Gem::Requirement.default}.a" unless bundler_version + + bundler_gem_version = Gem::Version.new(bundler_version) + + requirement = bundler_gem_version.approximate_recommendation + + return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0") + + requirement += ".a" if bundler_gem_version.prerelease? + + requirement end def load_bundler! ENV["BUNDLE_GEMFILE"] ||= gemfile - # must dup string for RG < 1.8 compatibility - activate_bundler(bundler_version.dup) + activate_bundler end - def activate_bundler(bundler_version) - if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0") - bundler_version = "< 2" - end + def activate_bundler gem_error = activation_error_handling do - gem "bundler", bundler_version + gem "bundler", bundler_requirement end return if gem_error.nil? require_error = activation_error_handling do require "bundler/version" end - return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION)) - warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`" + return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) + warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`" exit 42 end diff --git a/bin/rails b/bin/rails index 5191e692..7fd59cc7 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,29 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path('../../config/application', __FILE__) -require_relative '../config/boot' -require 'rails/commands' +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rails' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("railties", "rails") diff --git a/bin/setup b/bin/setup index acdb2c13..94fd4d79 100755 --- a/bin/setup +++ b/bin/setup @@ -1,29 +1,36 @@ #!/usr/bin/env ruby -require 'pathname' +require 'fileutils' +include FileUtils # path to your application root. -APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) +APP_ROOT = File.expand_path('..', __dir__) -Dir.chdir APP_ROOT do +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do # This script is a starting point to setup your application. - # Add necessary setup steps to this file: + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') - puts "== Installing dependencies ==" - system "gem install bundler --conservative" - system "bundle check || bundle install" + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') # puts "\n== Copying sample files ==" - # unless File.exist?("config/database.yml") - # system "cp config/database.yml.sample config/database.yml" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' # end puts "\n== Preparing database ==" - system "bin/rake db:setup" + system! 'bin/rails db:setup' puts "\n== Removing old logs and tempfiles ==" - system "rm -f log/*" - system "rm -rf tmp/cache" + system! 'bin/rails log:clear tmp:clear' puts "\n== Restarting application server ==" - system "touch tmp/restart.txt" + system! 'bin/rails restart' end diff --git a/bin/update b/bin/update new file mode 100755 index 00000000..58bfaed5 --- /dev/null +++ b/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/bin/yarn b/bin/yarn new file mode 100755 index 00000000..460dd565 --- /dev/null +++ b/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/config/application.rb b/config/application.rb index 766b0fbc..045851cf 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,4 +1,4 @@ -require File.expand_path('../boot', __FILE__) +require_relative 'boot' require 'rails/all' @@ -8,22 +8,12 @@ module CalagatorOrg class Application < Rails::Application - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. - - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. - config.time_zone = 'Pacific Time (US & Canada)' - - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - # config.i18n.default_locale = :de + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.0 - # Do not swallow errors in after_commit/after_rollback callbacks. - config.active_record.raise_in_transactional_callbacks = true - - # Allow embedding in IFRAMES - config.action_dispatch.default_headers['X-Frame-Options'] = "ALLOWALL" + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. end end diff --git a/config/boot.rb b/config/boot.rb index 6b750f00..30f5120d 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,3 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/cable.yml b/config/cable.yml new file mode 100644 index 00000000..8118acab --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: calagator_org_production diff --git a/config/blacklist.txt b/config/denylist.txt similarity index 100% rename from config/blacklist.txt rename to config/denylist.txt diff --git a/config/environment.rb b/config/environment.rb index ee8d90dc..426333bb 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ # Load the Rails application. -require File.expand_path('../application', __FILE__) +require_relative 'application' # Initialize the Rails application. Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index b55e2144..366e75ad 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -9,33 +9,53 @@ # Do not eager load code on boot. config.eager_load = false - # Show full error reports and disable caching. - config.consider_all_requests_local = true - config.action_controller.perform_caching = false + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false + config.action_mailer.perform_caching = false + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true - # Asset digests allow you to set far-future HTTP expiration dates on all assets, - # yet still be able to expire them through the digest params. - config.assets.digest = true - - # Adds additional error checking when serving assets at runtime. - # Checks for improperly declared sprockets dependencies. - # Raises helpful error messages. - config.assets.raise_runtime_errors = true + # Suppress logger output for asset requests. + config.assets.quiet = true # Raises error for missing translations # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + # config.file_watcher = ActiveSupport::EventedFileUpdateChecker end diff --git a/config/environments/production.rb b/config/environments/production.rb index 33c57ee5..5b613576 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -14,15 +14,13 @@ config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Enable Rack::Cache to put a simple HTTP cache in front of your application - # Add `rack-cache` to your Gemfile before enabling this. - # For large-scale production use, consider using a caching reverse proxy like - # NGINX, varnish or squid. - # config.action_dispatch.rack_cache = true + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier @@ -31,36 +29,41 @@ # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false - # Asset digests allow you to set far-future HTTP expiration dates on all assets, - # yet still be able to expire them through the digest params. - config.assets.digest = true - # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache - config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - # Use the lowest log level to ensure availability of diagnostic information - # when problems arise. config.log_level = :warn config.lograge.enabled = true # Prepend all log lines with the following tags. - # config.log_tags = [ :subdomain, :uuid ] - - # Use a different logger for distributed setups. - # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + config.log_tags = [ :request_id ] # Use a different cache store in production. # config.cache_store = :mem_cache_store - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = 'http://assets.example.com' + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "calagator_org_#{Rails.env}" + + config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. @@ -76,6 +79,16 @@ # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false end diff --git a/config/environments/test.rb b/config/environments/test.rb index 1c19f08b..0a38fd3c 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -12,9 +12,11 @@ # preloads Rails for running tests, you may have to set it to true. config.eager_load = false - # Configure static file server for tests with Cache-Control for performance. - config.serve_static_files = true - config.static_cache_control = 'public, max-age=3600' + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } # Show full error reports and disable caching. config.consider_all_requests_local = true @@ -26,14 +28,16 @@ # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false + # Store uploaded files on the local file system in a temporary directory + config.active_storage.service = :test + + config.action_mailer.perform_caching = false + # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test - # Randomize the order test cases are executed. - config.active_support.test_order = :random - # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr diff --git a/config/initializers/01_calagator.rb b/config/initializers/01_calagator.rb index 0290c9ce..b041c41b 100644 --- a/config/initializers/01_calagator.rb +++ b/config/initializers/01_calagator.rb @@ -16,14 +16,6 @@ config.admin_username = 'admin' config.admin_password = ENV['CALAGATOR_ADMIN_PASSWORD'] - # API key for Meetup.com, get your own from: http://www.meetup.com/meetup_api/key/ - config.meetup_api_key = ENV['MEETUP_API_KEY'] - - # Access token for Facebook: - # 1. Create a new app for your site at https://developers.facebook.com/apps - # 2. Visit https://developers.facebook.com/tools/access_token/ to find the "App Token" - config.facebook_access_token = ENV['FACEBOOK_ACCESS_TOKEN'] - # Search engine to use for searching events. # Values: :sql, :sunspot. Defaults to :sql. config.search_engine = :sunspot @@ -86,6 +78,6 @@ } # Patterns for detecting spam events and venues - config.blacklist_patterns = File.read(Rails.root.join('config', 'blacklist.txt')).lines.map{|l| Regexp.new(l) } + config.denylist_patterns = File.read(Rails.root.join('config', 'denylist.txt')).lines.map{|l| Regexp.new(l) } end diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb new file mode 100644 index 00000000..89d2efab --- /dev/null +++ b/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 01ef3e66..4b828e80 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -3,9 +3,12 @@ # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' -# Add additional assets to the asset load path +# Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') # Precompile additional assets. -# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. -# Rails.application.config.assets.precompile += %w( search.js ) +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb new file mode 100644 index 00000000..d3bcaa5e --- /dev/null +++ b/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb index 7f70458d..5a6a32d3 100644 --- a/config/initializers/cookies_serializer.rb +++ b/config/initializers/cookies_serializer.rb @@ -1,3 +1,5 @@ # Be sure to restart your server when you modify this file. +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/new_framework_defaults_5_2.rb b/config/initializers/new_framework_defaults_5_2.rb new file mode 100644 index 00000000..c383d072 --- /dev/null +++ b/config/initializers/new_framework_defaults_5_2.rb @@ -0,0 +1,38 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 5.2 upgrade. +# +# Once upgraded flip defaults one by one to migrate to the new default. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. + +# Make Active Record use stable #cache_key alongside new #cache_version method. +# This is needed for recyclable cache keys. +# Rails.application.config.active_record.cache_versioning = true + +# Use AES-256-GCM authenticated encryption for encrypted cookies. +# Also, embed cookie expiry in signed or encrypted cookies for increased security. +# +# This option is not backwards compatible with earlier Rails versions. +# It's best enabled when your entire app is migrated and stable on 5.2. +# +# Existing cookies will be converted on read then written with the new scheme. +# Rails.application.config.action_dispatch.use_authenticated_cookie_encryption = true + +# Use AES-256-GCM authenticated encryption as default cipher for encrypting messages +# instead of AES-256-CBC, when use_authenticated_message_encryption is set to true. +# Rails.application.config.active_support.use_authenticated_message_encryption = true + +# Add default protection from forgery to ActionController::Base instead of in +# ApplicationController. +# Rails.application.config.action_controller.default_protect_from_forgery = true + +# Store boolean values are in sqlite3 databases as 1 and 0 instead of 't' and +# 'f' after migrating old data. +# Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true + +# Use SHA-1 instead of MD5 to generate non-sensitive digests, such as the ETag header. +# Rails.application.config.active_support.use_sha1_digests = true + +# Make `form_with` generate id attributes for any generated HTML tags. +# Rails.application.config.action_view.form_with_generates_ids = true diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 33725e95..bbfc3961 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -5,10 +5,10 @@ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do - wrap_parameters format: [:json] if respond_to?(:wrap_parameters) + wrap_parameters format: [:json] end # To enable root element in JSON for ActiveRecord objects. # ActiveSupport.on_load(:active_record) do -# self.include_root_in_json = true +# self.include_root_in_json = true # end diff --git a/config/locales/en.yml b/config/locales/en.yml index 06539571..decc5a85 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -16,6 +16,16 @@ # # This would use the information in config/locales/es.yml. # +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# # To learn more, please read the Rails Internationalization guide # available at http://guides.rubyonrails.org/i18n.html. diff --git a/config/puma.rb b/config/puma.rb index c61efe26..2bd87207 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,29 +1,28 @@ -# typed: false -# frozen_string_literal: true - # Puma can serve each request in a thread from an internal thread pool. # The `threads` method setting takes two numbers: a minimum and maximum. # Any libraries that use thread pools should be configured to match # the maximum value specified for Puma. Default is set to 5 threads for minimum # and maximum; this matches the default thread size of Active Record. # -threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 } +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } threads threads_count, threads_count # Specifies the `port` that Puma will listen on to receive requests; default is 3000. # -port ENV.fetch('PORT') { 3000 } +port ENV.fetch("PORT") { 3000 } # Specifies the `environment` that Puma will run in. # -environment ENV.fetch('RAILS_ENV') { 'development' } +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } # Specifies the number of `workers` to boot in clustered mode. # Workers are forked webserver processes. If using threads and workers together # the concurrency of the application would be max `threads` * `workers`. # Workers do not work on JRuby or Windows (both of which do not support # processes). - workers ENV.fetch('WEB_CONCURRENCY') { 3 } worker_timeout ENV.fetch('WORKER_TIMEOUT') { 60 } @@ -31,30 +30,9 @@ # Use the `preload_app!` method when specifying a `workers` number. # This directive tells Puma to first boot the application and load code # before forking the application. This takes advantage of Copy On Write -# process behavior so workers use less memory. If you use this option -# you need to make sure to reconnect any threads in the `on_worker_boot` -# block. - +# process behavior so workers use less memory. +# preload_app! -# If you are preloading your application and using Active Record, it's -# recommended that you close any connections to the database before workers -# are forked to prevent connection leakage. - -before_fork do - ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord) -end - -# The code in the `on_worker_boot` will be called if you are using -# clustered mode by specifying a number of `workers`. After each worker -# process is booted, this block will be run. If you are using the `preload_app!` -# option, you will want to use this block to reconnect to any threads -# or connections that may have been created at application boot, as Ruby -# cannot share connections between processes. - -on_worker_boot do - ActiveRecord::Base.establish_connection if defined?(ActiveRecord) -end - # Allow puma to be restarted by `rails restart` command. plugin :tmp_restart diff --git a/config/storage.yml b/config/storage.yml new file mode 100644 index 00000000..d32f76e8 --- /dev/null +++ b/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/db/migrate/20150604010216_create_events.calagator.rb b/db/migrate/20150604010216_create_events.calagator.rb index 59038b97..c540d6fc 100644 --- a/db/migrate/20150604010216_create_events.calagator.rb +++ b/db/migrate/20150604010216_create_events.calagator.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 1) -class CreateEvents < ActiveRecord::Migration + +class CreateEvents < ActiveRecord::Migration[4.2] def self.up create_table :events do |t| t.string :title diff --git a/db/migrate/20150604010217_create_venues.calagator.rb b/db/migrate/20150604010217_create_venues.calagator.rb index 32c8c9e1..d55dd8d1 100644 --- a/db/migrate/20150604010217_create_venues.calagator.rb +++ b/db/migrate/20150604010217_create_venues.calagator.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 2) -class CreateVenues < ActiveRecord::Migration + +class CreateVenues < ActiveRecord::Migration[4.2] def self.up create_table :venues do |t| t.string :title @@ -9,7 +11,6 @@ def self.up t.timestamps end - end def self.down diff --git a/db/migrate/20150604010218_create_sources.calagator.rb b/db/migrate/20150604010218_create_sources.calagator.rb index 941c4963..cacf7e7a 100644 --- a/db/migrate/20150604010218_create_sources.calagator.rb +++ b/db/migrate/20150604010218_create_sources.calagator.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 3) -class CreateSources < ActiveRecord::Migration + +class CreateSources < ActiveRecord::Migration[4.2] def self.up create_table :sources do |t| t.string :title diff --git a/db/migrate/20150604010219_add_detailed_fields_to_venue.calagator.rb b/db/migrate/20150604010219_add_detailed_fields_to_venue.calagator.rb index 414c4573..6b85231f 100644 --- a/db/migrate/20150604010219_add_detailed_fields_to_venue.calagator.rb +++ b/db/migrate/20150604010219_add_detailed_fields_to_venue.calagator.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 4) -class AddDetailedFieldsToVenue < ActiveRecord::Migration + +class AddDetailedFieldsToVenue < ActiveRecord::Migration[4.2] def self.up add_column :venues, :street_address, :string add_column :venues, :locality, :string diff --git a/db/migrate/20150604010220_add_end_time_to_events.calagator.rb b/db/migrate/20150604010220_add_end_time_to_events.calagator.rb index 4728d668..ec7da46a 100644 --- a/db/migrate/20150604010220_add_end_time_to_events.calagator.rb +++ b/db/migrate/20150604010220_add_end_time_to_events.calagator.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 5) -class AddEndTimeToEvents < ActiveRecord::Migration + +class AddEndTimeToEvents < ActiveRecord::Migration[4.2] def self.up add_column :events, :end_time, :timestamp end diff --git a/db/migrate/20150604010221_add_source_id_to_events.calagator.rb b/db/migrate/20150604010221_add_source_id_to_events.calagator.rb index 7a9277b5..0da5d865 100644 --- a/db/migrate/20150604010221_add_source_id_to_events.calagator.rb +++ b/db/migrate/20150604010221_add_source_id_to_events.calagator.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 6) -class AddSourceIdToEvents < ActiveRecord::Migration + +class AddSourceIdToEvents < ActiveRecord::Migration[4.2] def self.up add_column :events, :source_id, :integer end diff --git a/db/migrate/20150604010222_add_source_id_to_venues.calagator.rb b/db/migrate/20150604010222_add_source_id_to_venues.calagator.rb index af8b5101..77d53aa9 100644 --- a/db/migrate/20150604010222_add_source_id_to_venues.calagator.rb +++ b/db/migrate/20150604010222_add_source_id_to_venues.calagator.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 8) -class AddSourceIdToVenues < ActiveRecord::Migration + +class AddSourceIdToVenues < ActiveRecord::Migration[4.2] def self.up add_column :venues, :source_id, :integer end @@ -8,4 +10,3 @@ def self.down remove_column :venues, :source_id end end - diff --git a/db/migrate/20150604010223_add_duplicate_of_column_to_venues.calagator.rb b/db/migrate/20150604010223_add_duplicate_of_column_to_venues.calagator.rb index f9673432..29290151 100644 --- a/db/migrate/20150604010223_add_duplicate_of_column_to_venues.calagator.rb +++ b/db/migrate/20150604010223_add_duplicate_of_column_to_venues.calagator.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 9) -class AddDuplicateOfColumnToVenues < ActiveRecord::Migration + +class AddDuplicateOfColumnToVenues < ActiveRecord::Migration[4.2] def self.up add_column :venues, :duplicate_of_id, :integer end diff --git a/db/migrate/20150604010224_add_duplicate_of_column_to_events.calagator.rb b/db/migrate/20150604010224_add_duplicate_of_column_to_events.calagator.rb index 207341dd..46fab84b 100644 --- a/db/migrate/20150604010224_add_duplicate_of_column_to_events.calagator.rb +++ b/db/migrate/20150604010224_add_duplicate_of_column_to_events.calagator.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 10) -class AddDuplicateOfColumnToEvents < ActiveRecord::Migration + +class AddDuplicateOfColumnToEvents < ActiveRecord::Migration[4.2] def self.up add_column :events, :duplicate_of_id, :integer end diff --git a/db/migrate/20150604010225_change_lat_long_type.calagator.rb b/db/migrate/20150604010225_change_lat_long_type.calagator.rb index cef66a3b..31dabfe3 100644 --- a/db/migrate/20150604010225_change_lat_long_type.calagator.rb +++ b/db/migrate/20150604010225_change_lat_long_type.calagator.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 11) -class ChangeLatLongType < ActiveRecord::Migration + +class ChangeLatLongType < ActiveRecord::Migration[4.2] def self.up # :decimal is more precise than :float, and we need that for lat/long. - change_column :venues, :latitude, :decimal, :precision => 15, :scale => 10 - change_column :venues, :longitude, :decimal, :precision => 15, :scale => 10 + change_column :venues, :latitude, :decimal, precision: 15, scale: 10 + change_column :venues, :longitude, :decimal, precision: 15, scale: 10 end def self.down diff --git a/db/migrate/20150604010226_add_source_reimport.calagator.rb b/db/migrate/20150604010226_add_source_reimport.calagator.rb index 5ea4de7a..0aa42ac5 100644 --- a/db/migrate/20150604010226_add_source_reimport.calagator.rb +++ b/db/migrate/20150604010226_add_source_reimport.calagator.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 12) -class AddSourceReimport < ActiveRecord::Migration + +class AddSourceReimport < ActiveRecord::Migration[4.2] def self.up add_column :sources, :reimport, :boolean end diff --git a/db/migrate/20150604010227_change_end_time_to_duration.calagator.rb b/db/migrate/20150604010227_change_end_time_to_duration.calagator.rb index 7c653680..ff482814 100644 --- a/db/migrate/20150604010227_change_end_time_to_duration.calagator.rb +++ b/db/migrate/20150604010227_change_end_time_to_duration.calagator.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 13) -class ChangeEndTimeToDuration < ActiveRecord::Migration + +class ChangeEndTimeToDuration < ActiveRecord::Migration[4.2] def self.up add_column :events, :duration, :integer remove_column :events, :end_time diff --git a/db/migrate/20150604010228_remove_format_type_from_source.calagator.rb b/db/migrate/20150604010228_remove_format_type_from_source.calagator.rb index 7d90d56b..36742fd7 100644 --- a/db/migrate/20150604010228_remove_format_type_from_source.calagator.rb +++ b/db/migrate/20150604010228_remove_format_type_from_source.calagator.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 14) -class RemoveFormatTypeFromSource < ActiveRecord::Migration + +class RemoveFormatTypeFromSource < ActiveRecord::Migration[4.2] def self.up remove_column :sources, :format_type end diff --git a/db/migrate/20150604010229_create_updates.calagator.rb b/db/migrate/20150604010229_create_updates.calagator.rb index a249d7d4..fe28764b 100644 --- a/db/migrate/20150604010229_create_updates.calagator.rb +++ b/db/migrate/20150604010229_create_updates.calagator.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 15) -class CreateUpdates < ActiveRecord::Migration + +class CreateUpdates < ActiveRecord::Migration[4.2] def self.up create_table :updates do |t| - t.integer "source_id" - t.text "status" + t.integer 'source_id' + t.text 'status' t.timestamps end add_column :sources, :next_update, :datetime diff --git a/db/migrate/20150604010230_remove_next_update_from_source.calagator.rb b/db/migrate/20150604010230_remove_next_update_from_source.calagator.rb index edc9817e..d893dd60 100644 --- a/db/migrate/20150604010230_remove_next_update_from_source.calagator.rb +++ b/db/migrate/20150604010230_remove_next_update_from_source.calagator.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 16) -class RemoveNextUpdateFromSource < ActiveRecord::Migration + +class RemoveNextUpdateFromSource < ActiveRecord::Migration[4.2] def self.up remove_column :sources, :next_update end diff --git a/db/migrate/20150604010231_change_duration_to_end_time.calagator.rb b/db/migrate/20150604010231_change_duration_to_end_time.calagator.rb index db912e4c..371b8cdb 100644 --- a/db/migrate/20150604010231_change_duration_to_end_time.calagator.rb +++ b/db/migrate/20150604010231_change_duration_to_end_time.calagator.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 20080705163959) -class ChangeDurationToEndTime < ActiveRecord::Migration + +class ChangeDurationToEndTime < ActiveRecord::Migration[4.2] def self.up add_column :events, :end_time, :datetime remove_column :events, :duration diff --git a/db/migrate/20150604010232_create_tags_and_taggings.calagator.rb b/db/migrate/20150604010232_create_tags_and_taggings.calagator.rb index ae2dcb2c..eec652e6 100644 --- a/db/migrate/20150604010232_create_tags_and_taggings.calagator.rb +++ b/db/migrate/20150604010232_create_tags_and_taggings.calagator.rb @@ -1,23 +1,23 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 20080705164959) # A migration to add tables for Tag and Tagging. This file is automatically generated and added to your app if you run the tagging generator included with has_many_polymorphs. -class CreateTagsAndTaggings < ActiveRecord::Migration - +class CreateTagsAndTaggings < ActiveRecord::Migration[4.2] # Add the new tables. def self.up create_table :tags do |t| - t.column :name, :string, :null => false + t.column :name, :string, null: false end - add_index :tags, :name, :unique => true + add_index :tags, :name, unique: true create_table :taggings do |t| - t.column :tag_id, :integer, :null => false - t.column :taggable_id, :integer, :null => false - t.column :taggable_type, :string, :null => false + t.column :tag_id, :integer, null: false + t.column :taggable_id, :integer, null: false + t.column :taggable_type, :string, null: false # t.column :position, :integer # Uncomment this if you need to use acts_as_list. end - add_index :taggings, [:tag_id, :taggable_id, :taggable_type], :unique => true + add_index :taggings, %i[tag_id taggable_id taggable_type], unique: true end # Remove the tables. @@ -25,5 +25,4 @@ def self.down drop_table :tags drop_table :taggings end - end diff --git a/db/migrate/20150604010233_create_versioned_events.calagator.rb b/db/migrate/20150604010233_create_versioned_events.calagator.rb index d98ea30c..4ff4d634 100644 --- a/db/migrate/20150604010233_create_versioned_events.calagator.rb +++ b/db/migrate/20150604010233_create_versioned_events.calagator.rb @@ -1,26 +1,28 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 20081011181519) -class CreateVersionedEvents < ActiveRecord::Migration + +class CreateVersionedEvents < ActiveRecord::Migration[4.2] # NOTE: This migration's contents have been commented-out because they relied # on the old +acts_as_versioned+ plugin that has since replaced with the # +papertrail+ plugin. def self.up -### Event.create_versioned_table do |t| -### t.string "title" -### t.text "description" -### t.datetime "start_time" -### t.string "url" -### t.datetime "created_at" -### t.datetime "updated_at" -### t.integer "venue_id" -### t.integer "source_id" -### t.integer "duplicate_of_id" -### t.datetime "end_time" -### t.integer "version" -### end + ### Event.create_versioned_table do |t| + ### t.string "title" + ### t.text "description" + ### t.datetime "start_time" + ### t.string "url" + ### t.datetime "created_at" + ### t.datetime "updated_at" + ### t.integer "venue_id" + ### t.integer "source_id" + ### t.integer "duplicate_of_id" + ### t.datetime "end_time" + ### t.integer "version" + ### end end def self.down -### Event.drop_versioned_table + ### Event.drop_versioned_table end end diff --git a/db/migrate/20150604010234_create_versioned_venues.calagator.rb b/db/migrate/20150604010234_create_versioned_venues.calagator.rb index ce5ffcd2..cb95ba00 100644 --- a/db/migrate/20150604010234_create_versioned_venues.calagator.rb +++ b/db/migrate/20150604010234_create_versioned_venues.calagator.rb @@ -1,33 +1,35 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 20081011193124) -class CreateVersionedVenues < ActiveRecord::Migration + +class CreateVersionedVenues < ActiveRecord::Migration[4.2] # NOTE: This migration's contents have been commented-out because they relied # on the old +acts_as_versioned+ plugin that we've since replaced with the # +papertrail+ plugin. # def self.up -### Venue.create_versioned_table do |t| -### t.string "title" -### t.text "description" -### t.string "address" -### t.string "url" -### t.datetime "created_at" -### t.datetime "updated_at" -### t.string "street_address" -### t.string "locality" -### t.string "region" -### t.string "postal_code" -### t.string "country" -### t.decimal "latitude" -### t.decimal "longitude" -### t.string "email" -### t.string "telephone" -### t.integer "source_id" -### t.integer "duplicate_of_id" -### t.integer "version" -### end + ### Venue.create_versioned_table do |t| + ### t.string "title" + ### t.text "description" + ### t.string "address" + ### t.string "url" + ### t.datetime "created_at" + ### t.datetime "updated_at" + ### t.string "street_address" + ### t.string "locality" + ### t.string "region" + ### t.string "postal_code" + ### t.string "country" + ### t.decimal "latitude" + ### t.decimal "longitude" + ### t.string "email" + ### t.string "telephone" + ### t.integer "source_id" + ### t.integer "duplicate_of_id" + ### t.integer "version" + ### end end def self.down -### Venue.drop_versioned_table + ### Venue.drop_versioned_table end end diff --git a/db/migrate/20150604010235_add_rrule_to_events.calagator.rb b/db/migrate/20150604010235_add_rrule_to_events.calagator.rb index d6cfadf2..6d5d88cc 100644 --- a/db/migrate/20150604010235_add_rrule_to_events.calagator.rb +++ b/db/migrate/20150604010235_add_rrule_to_events.calagator.rb @@ -1,16 +1,18 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 20081115190515) -class AddRruleToEvents < ActiveRecord::Migration + +class AddRruleToEvents < ActiveRecord::Migration[4.2] # NOTE: Some of this migration's contents have been commented-out because # they used tables created for the old +acts_as_versioned+ plugin that has # since replaced with the +papertrail+ plugin. def self.up add_column :events, :rrule, :string -### add_column :event_versions, :rrule, :string + ### add_column :event_versions, :rrule, :string end def self.down remove_column :events, :rrule -### remove_column :event_versions, :rrule + ### remove_column :event_versions, :rrule end end diff --git a/db/migrate/20150604010236_create_versions.calagator.rb b/db/migrate/20150604010236_create_versions.calagator.rb index 5ad340a1..9cb2df81 100644 --- a/db/migrate/20150604010236_create_versions.calagator.rb +++ b/db/migrate/20150604010236_create_versions.calagator.rb @@ -1,19 +1,21 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 20090912082129) -class CreateVersions < ActiveRecord::Migration + +class CreateVersions < ActiveRecord::Migration[4.2] def self.up create_table :versions do |t| - t.string :item_type, :null => false - t.integer :item_id, :null => false - t.string :event, :null => false + t.string :item_type, null: false + t.integer :item_id, null: false + t.string :event, null: false t.string :whodunnit t.text :object t.datetime :created_at end - add_index :versions, [:item_type, :item_id] + add_index :versions, %i[item_type item_id] end def self.down - remove_index :versions, [:item_type, :item_id] + remove_index :versions, %i[item_type item_id] drop_table :versions end end diff --git a/db/migrate/20150604010237_add_closed_flag_to_venues.calagator.rb b/db/migrate/20150604010237_add_closed_flag_to_venues.calagator.rb index 70c9c7bb..a7dc8338 100644 --- a/db/migrate/20150604010237_add_closed_flag_to_venues.calagator.rb +++ b/db/migrate/20150604010237_add_closed_flag_to_venues.calagator.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 20110219205156) -class AddClosedFlagToVenues < ActiveRecord::Migration + +class AddClosedFlagToVenues < ActiveRecord::Migration[4.2] def self.up - add_column :venues, :closed, :boolean, :default => false + add_column :venues, :closed, :boolean, default: false end def self.down diff --git a/db/migrate/20150604010238_add_wifi_flag_to_venues.calagator.rb b/db/migrate/20150604010238_add_wifi_flag_to_venues.calagator.rb index bb9abcfb..98666cb1 100644 --- a/db/migrate/20150604010238_add_wifi_flag_to_venues.calagator.rb +++ b/db/migrate/20150604010238_add_wifi_flag_to_venues.calagator.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 20110220001008) -class AddWifiFlagToVenues < ActiveRecord::Migration + +class AddWifiFlagToVenues < ActiveRecord::Migration[4.2] def self.up - add_column :venues, :wifi, :boolean, :default => false + add_column :venues, :wifi, :boolean, default: false end def self.down diff --git a/db/migrate/20150604010239_add_access_notes_to_venues.calagator.rb b/db/migrate/20150604010239_add_access_notes_to_venues.calagator.rb index 2de91d61..7fe99bb7 100644 --- a/db/migrate/20150604010239_add_access_notes_to_venues.calagator.rb +++ b/db/migrate/20150604010239_add_access_notes_to_venues.calagator.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 20110220011427) -class AddAccessNotesToVenues < ActiveRecord::Migration + +class AddAccessNotesToVenues < ActiveRecord::Migration[4.2] def self.up add_column :venues, :access_notes, :text end diff --git a/db/migrate/20150604010240_add_events_count_to_venues.calagator.rb b/db/migrate/20150604010240_add_events_count_to_venues.calagator.rb index e7880dbf..28aabb62 100644 --- a/db/migrate/20150604010240_add_events_count_to_venues.calagator.rb +++ b/db/migrate/20150604010240_add_events_count_to_venues.calagator.rb @@ -1,8 +1,11 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 20110220031117) -class AddEventsCountToVenues < ActiveRecord::Migration + +class AddEventsCountToVenues < ActiveRecord::Migration[4.2] def self.up add_column :venues, :events_count, :integer end + def self.down remove_column :venues, :events_count end diff --git a/db/migrate/20150604010241_add_venue_details_to_events.calagator.rb b/db/migrate/20150604010241_add_venue_details_to_events.calagator.rb index 50b7670b..0287a631 100644 --- a/db/migrate/20150604010241_add_venue_details_to_events.calagator.rb +++ b/db/migrate/20150604010241_add_venue_details_to_events.calagator.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 20110604174521) -class AddVenueDetailsToEvents < ActiveRecord::Migration + +class AddVenueDetailsToEvents < ActiveRecord::Migration[4.2] def self.up add_column :events, :venue_details, :text end diff --git a/db/migrate/20150604010242_acts_as_taggable_on_migration.calagator.rb b/db/migrate/20150604010242_acts_as_taggable_on_migration.calagator.rb index b45c0984..2e9d892a 100644 --- a/db/migrate/20150604010242_acts_as_taggable_on_migration.calagator.rb +++ b/db/migrate/20150604010242_acts_as_taggable_on_migration.calagator.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 20110717231316) -class ActsAsTaggableOnMigration < ActiveRecord::Migration + +class ActsAsTaggableOnMigration < ActiveRecord::Migration[4.2] def self.up # We already have a Tag model with a name # create_table :tags do |t| @@ -29,21 +31,21 @@ def self.up # t.datetime :created_at # end - remove_index :taggings, :column => ["tag_id", "taggable_id", "taggable_type"] + remove_index :taggings, column: %w[tag_id taggable_id taggable_type] add_index :taggings, :tag_id - add_index :taggings, [:taggable_id, :taggable_type, :context] + add_index :taggings, %i[taggable_id taggable_type context] end def self.down remove_index :taggings, :tag_id - remove_index :taggings, :column => [:taggable_id, :taggable_type, :context] + remove_index :taggings, column: %i[taggable_id taggable_type context] remove_column :taggings, :tagger_id remove_column :taggings, :tagger_type remove_column :taggings, :context remove_column :taggings, :created_at - add_index "taggings", ["tag_id", "taggable_id", "taggable_type"], :name => "index_taggings_on_tag_id_and_taggable_id_and_taggable_type", :unique => true + add_index 'taggings', %w[tag_id taggable_id taggable_type], name: 'index_taggings_on_tag_id_and_taggable_id_and_taggable_type', unique: true # drop_table :taggings # drop_table :tags diff --git a/db/migrate/20150604010243_cleanup.calagator.rb b/db/migrate/20150604010243_cleanup.calagator.rb index de8a24d7..8d9676a3 100644 --- a/db/migrate/20150604010243_cleanup.calagator.rb +++ b/db/migrate/20150604010243_cleanup.calagator.rb @@ -1,15 +1,15 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 20120709092821) -class Cleanup < ActiveRecord::Migration + +class Cleanup < ActiveRecord::Migration[4.2] # Remove obsolete tables and columns that may have been left behind by other migrations. def self.up - if ActiveRecord::Base.connection.columns('venues').map(&:name).include?("version") + if ActiveRecord::Base.connection.columns('venues').map(&:name).include?('version') remove_column :venues, :version end %w[event_versions venue_versions].each do |table| - if ActiveRecord::Base.connection.tables.include?(table) - drop_table table - end + drop_table table if ActiveRecord::Base.connection.tables.include?(table) end end end diff --git a/db/migrate/20150604010244_specify_venues_latitude_and_longitude_precision.calagator.rb b/db/migrate/20150604010244_specify_venues_latitude_and_longitude_precision.calagator.rb index 428f7b5e..f7bf800a 100644 --- a/db/migrate/20150604010244_specify_venues_latitude_and_longitude_precision.calagator.rb +++ b/db/migrate/20150604010244_specify_venues_latitude_and_longitude_precision.calagator.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 20120831234448) -class SpecifyVenuesLatitudeAndLongitudePrecision < ActiveRecord::Migration + +class SpecifyVenuesLatitudeAndLongitudePrecision < ActiveRecord::Migration[4.2] def up - change_column :venues, :latitude, :decimal, :precision => 7, :scale => 4 - change_column :venues, :longitude, :decimal, :precision => 7, :scale => 4 + change_column :venues, :latitude, :decimal, precision: 7, scale: 4 + change_column :venues, :longitude, :decimal, precision: 7, scale: 4 end def down diff --git a/db/migrate/20150604010245_remove_updates.calagator.rb b/db/migrate/20150604010245_remove_updates.calagator.rb index ae162af0..63e08b0a 100644 --- a/db/migrate/20150604010245_remove_updates.calagator.rb +++ b/db/migrate/20150604010245_remove_updates.calagator.rb @@ -1,13 +1,15 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 20150206085809) -class RemoveUpdates < ActiveRecord::Migration + +class RemoveUpdates < ActiveRecord::Migration[4.2] def up drop_table :updates end def down create_table :updates do |t| - t.integer "source_id" - t.text "status" + t.integer 'source_id' + t.text 'status' t.timestamps end end diff --git a/db/migrate/20150604010246_add_locked_status_to_events.calagator.rb b/db/migrate/20150604010246_add_locked_status_to_events.calagator.rb index 28167667..973f20b8 100644 --- a/db/migrate/20150604010246_add_locked_status_to_events.calagator.rb +++ b/db/migrate/20150604010246_add_locked_status_to_events.calagator.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 20150207231355) -class AddLockedStatusToEvents < ActiveRecord::Migration + +class AddLockedStatusToEvents < ActiveRecord::Migration[4.2] def change - add_column :events, :locked, :boolean, :default => false + add_column :events, :locked, :boolean, default: false end end diff --git a/db/migrate/20150604010247_add_taggings_counter_cache_to_tags.calagator.rb b/db/migrate/20150604010247_add_taggings_counter_cache_to_tags.calagator.rb index 20b104b3..c166d5f9 100644 --- a/db/migrate/20150604010247_add_taggings_counter_cache_to_tags.calagator.rb +++ b/db/migrate/20150604010247_add_taggings_counter_cache_to_tags.calagator.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 20150407014752) -class AddTaggingsCounterCacheToTags < ActiveRecord::Migration + +class AddTaggingsCounterCacheToTags < ActiveRecord::Migration[4.2] def self.up add_column :tags, :taggings_count, :integer, default: 0 diff --git a/db/migrate/20150604010248_change_collation_for_tag_names.calagator.rb b/db/migrate/20150604010248_change_collation_for_tag_names.calagator.rb index 4fdae7f9..e8304c06 100644 --- a/db/migrate/20150604010248_change_collation_for_tag_names.calagator.rb +++ b/db/migrate/20150604010248_change_collation_for_tag_names.calagator.rb @@ -1,10 +1,12 @@ +# frozen_string_literal: true # This migration comes from calagator (originally 20150407014754) + # This migration is added to circumvent issue #623 and have special characters # work properly -class ChangeCollationForTagNames < ActiveRecord::Migration +class ChangeCollationForTagNames < ActiveRecord::Migration[4.2] def up if ActsAsTaggableOn::Utils.using_mysql? - execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;") + execute('ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;') end end end diff --git a/db/migrate/20150610174730_update_versions_with_namespace.rb b/db/migrate/20150610174730_update_versions_with_namespace.rb deleted file mode 100644 index 19238652..00000000 --- a/db/migrate/20150610174730_update_versions_with_namespace.rb +++ /dev/null @@ -1,13 +0,0 @@ -class UpdateVersionsWithNamespace < ActiveRecord::Migration - def up - execute "update versions set item_type = 'Calagator::Venue' where item_type = 'Venue';" - execute "update versions set item_type = 'Calagator::Event' where item_type = 'Event';" - execute "update versions set item_type = 'Calagator::Source' where item_type = 'Source';" - end - - def down - execute "update versions set item_type = 'Venue' where item_type = 'Calagator::Venue';" - execute "update versions set item_type = 'Event' where item_type = 'Calagator::Event';" - execute "update versions set item_type = 'Source' where item_type = 'Calagator::Source';" - end -end diff --git a/db/migrate/20211231002189_drop_reimport_column_from_sources.calagator.rb b/db/migrate/20211231002189_drop_reimport_column_from_sources.calagator.rb new file mode 100644 index 00000000..33a220c2 --- /dev/null +++ b/db/migrate/20211231002189_drop_reimport_column_from_sources.calagator.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true +# This migration comes from calagator (originally 20150702171204) + +class DropReimportColumnFromSources < ActiveRecord::Migration[4.2] + def self.up + remove_column :sources, :reimport + end + + def self.down + add_column :sources, :reimport, :boolean + end +end diff --git a/db/migrate/20211231002190_add_missing_indexes_on_taggings.calagator.rb b/db/migrate/20211231002190_add_missing_indexes_on_taggings.calagator.rb new file mode 100644 index 00000000..60272be3 --- /dev/null +++ b/db/migrate/20211231002190_add_missing_indexes_on_taggings.calagator.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true +# This migration comes from calagator (originally 20200327040656) + +# This migration comes from acts_as_taggable_on_engine (originally 6) +if ActiveRecord.gem_version >= Gem::Version.new('5.0') + class AddMissingIndexesOnTaggings < ActiveRecord::Migration[4.2]; end +else + class AddMissingIndexesOnTaggings < ActiveRecord::Migration; end +end +AddMissingIndexesOnTaggings.class_eval do + def change + add_index :taggings, :tag_id unless index_exists? :taggings, :tag_id + add_index :taggings, :taggable_id unless index_exists? :taggings, :taggable_id + add_index :taggings, :taggable_type unless index_exists? :taggings, :taggable_type + add_index :taggings, :tagger_id unless index_exists? :taggings, :tagger_id + add_index :taggings, :context unless index_exists? :taggings, :context + + unless index_exists? :taggings, %i[tagger_id tagger_type] + add_index :taggings, %i[tagger_id tagger_type] + end + + unless index_exists? :taggings, %i[taggable_id taggable_type tagger_id context], name: 'taggings_idy' + add_index :taggings, %i[taggable_id taggable_type tagger_id context], name: 'taggings_idy' + end + end +end diff --git a/db/schema.rb b/db/schema.rb index a624caf8..cfa86d9c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. @@ -11,86 +10,89 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150610174730) do +ActiveRecord::Schema.define(version: 2021_12_31_002190) do create_table "events", force: :cascade do |t| - t.string "title", limit: 255 - t.text "description" + t.string "title", limit: 255 + t.text "description" t.datetime "start_time" - t.string "url", limit: 255 + t.string "url", limit: 255 t.datetime "created_at" t.datetime "updated_at" - t.integer "venue_id" - t.integer "source_id" - t.integer "duplicate_of_id" + t.integer "venue_id" + t.integer "source_id" + t.integer "duplicate_of_id" t.datetime "end_time" - t.integer "version" - t.string "rrule", limit: 255 - t.text "venue_details" - t.boolean "locked", default: false + t.integer "version" + t.string "rrule", limit: 255 + t.text "venue_details" + t.boolean "locked", default: false end create_table "sources", force: :cascade do |t| - t.string "title", limit: 255 - t.string "url", limit: 255 + t.string "title", limit: 255 + t.string "url", limit: 255 t.datetime "imported_at" t.datetime "created_at" t.datetime "updated_at" - t.boolean "reimport" end create_table "taggings", force: :cascade do |t| - t.integer "tag_id", null: false - t.integer "taggable_id", null: false - t.string "taggable_type", limit: 255, null: false - t.integer "tagger_id" - t.string "tagger_type", limit: 255 - t.string "context", limit: 255 + t.integer "tag_id", null: false + t.integer "taggable_id", null: false + t.string "taggable_type", limit: 255, null: false + t.integer "tagger_id" + t.string "tagger_type", limit: 255 + t.string "context", limit: 255 t.datetime "created_at" + t.index ["context"], name: "index_taggings_on_context" + t.index ["tag_id"], name: "index_taggings_on_tag_id" + t.index ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context" + t.index ["taggable_id", "taggable_type", "tagger_id", "context"], name: "taggings_idy" + t.index ["taggable_id"], name: "index_taggings_on_taggable_id" + t.index ["taggable_type"], name: "index_taggings_on_taggable_type" + t.index ["tagger_id", "tagger_type"], name: "index_taggings_on_tagger_id_and_tagger_type" + t.index ["tagger_id"], name: "index_taggings_on_tagger_id" end - add_index "taggings", ["tag_id"], name: "index_taggings_on_tag_id" - add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context" - create_table "tags", force: :cascade do |t| t.string "name", limit: 255, null: false + t.integer "taggings_count", default: 0 + t.index ["name"], name: "index_tags_on_name", unique: true end - add_index "tags", ["name"], name: "index_tags_on_name", unique: true - create_table "venues", force: :cascade do |t| - t.string "title", limit: 255 - t.text "description" - t.string "address", limit: 255 - t.string "url", limit: 255 + t.string "title", limit: 255 + t.text "description" + t.string "address", limit: 255 + t.string "url", limit: 255 t.datetime "created_at" t.datetime "updated_at" - t.string "street_address", limit: 255 - t.string "locality", limit: 255 - t.string "region", limit: 255 - t.string "postal_code", limit: 255 - t.string "country", limit: 255 - t.decimal "latitude", precision: 7, scale: 4 - t.decimal "longitude", precision: 7, scale: 4 - t.string "email", limit: 255 - t.string "telephone", limit: 255 - t.integer "source_id" - t.integer "duplicate_of_id" - t.boolean "closed", default: false - t.boolean "wifi", default: false - t.text "access_notes" - t.integer "events_count" + t.string "street_address", limit: 255 + t.string "locality", limit: 255 + t.string "region", limit: 255 + t.string "postal_code", limit: 255 + t.string "country", limit: 255 + t.decimal "latitude", precision: 7, scale: 4 + t.decimal "longitude", precision: 7, scale: 4 + t.string "email", limit: 255 + t.string "telephone", limit: 255 + t.integer "source_id" + t.integer "duplicate_of_id" + t.boolean "closed", default: false + t.boolean "wifi", default: false + t.text "access_notes" + t.integer "events_count" end create_table "versions", force: :cascade do |t| - t.string "item_type", limit: 255, null: false - t.integer "item_id", null: false - t.string "event", limit: 255, null: false - t.string "whodunnit", limit: 255 - t.text "object" + t.string "item_type", limit: 255, null: false + t.integer "item_id", null: false + t.string "event", limit: 255, null: false + t.string "whodunnit", limit: 255 + t.text "object" t.datetime "created_at" + t.index ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id" end - add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id" - end diff --git a/tmp/cache/.gitkeep b/tmp/cache/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tmp/pids/.gitkeep b/tmp/pids/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tmp/sockets/.gitkeep b/tmp/sockets/.gitkeep new file mode 100644 index 00000000..e69de29b