Skip to content

Conversation

@leonardow-unep-wcmc
Copy link
Contributor

@leonardow-unep-wcmc leonardow-unep-wcmc commented Feb 5, 2024

Upgrade strategy: Keep the same behaviour as possible, not intend to refactor any code unless necessary.

Major Upgrade

  • Ruby from 2.3.1 to 3.0.6 (EOL @ 31 Mar 2024)
  • Rails from 4.0.6 to 6.1.7.6
  • Try to upgrade all the gems used in this project to latest version
  • rspec to version 3 syntax

New (including but not limited to)

  • Email now send through background job
  • A new docker container named cap-deploy. For capistrano deploy
  • Following ahoy_matey readme to reconfigure for GDPR
  • [Deploy production] Disable rebuild_job_daily cron job in Sidekiq->Cron admin page, so the rebuild task only run on Saturday.

Replaced (including but not limited to)

  • cancan with cancancan
  • traco with mobility
  • whenever with sidekiq-cron. Make sure remove all cronjob in crontab when deploy to production
  • protected_attributes with build-in strong parameters
  • webrick with puma (for development)
  • factory_girl with factory_bot (for testing)

Things not being upgrade

  • Keep using assets pipeline. Not migrate to webpacker which was introduced in Rails 6, as it was deprecated in Rails 7
  • Keep using secrets.yml. Not migrate to new credentials which was introduced in Rails 5.2
  • Keep using jquery_ujs. Not migrate to new rails-ujs which was introduced in Rails 5.2
  • Keep using database_cleaner. The current test setup not working well with build-in transactional test which was introduced in Rails 5.1
  • Keep using carrierwave. Not migrate to ActiveStorage which was introduced in Rails 5.2
  • Keep using worker instead of ActiveJob for existing tasks, due to sidekiq-unique-jobs doesn't work with ActiveJob
  • Most frontend JS/CSS library keep unchanged. However, some related gems (wrapper only) are being removed from this project, to release the gems' dependency which prevent us to upgrade Rails. Those assets are copied to vendor or app/assets (Thanks @pdl)
  • aws-sdk v2, should upgrade to v3
  • bootstrap-sass 2, upgrade will change to v3 css, may not compatible

Should upgrade but can't

Removed (including but not limited to)

  • clerk. Re-implement ourselves
  • timecop. Replaced with build-in methods which was introduced in Rails 4.2
  • rails-observer, which removed from Rails core since Rails 4.0. Moved those callbacks back to model/mixin/inherited class, as well as refactoring, move anything not within DB transaction, to after_commit (e.g. cache related; perform async job).

Deprecated gem, should find replacement

  • inherited_resources
  • actionpack-action_caching and actionpack-page_caching, which was removed from Rails core since Rails 4 - now removed
  • active_model_serializers
  • susy
  • nested_form

Further suggestions

  • Consider upgrade bundler to 2
  • Consider implement proper CORS with rack-cors
  • kaminari migrate to pagy

leonardow-unep-wcmc and others added 30 commits January 18, 2024 15:59
… so safe to remove the dependancy gem in our Gemfile.
…ient js libraries

Fixes issues caused by updating versions of the ember-rails and ember-data-source gems
by running the following:

    rails generate ember:install --tag=v1.6.1 --ember
    rails generate ember:install --tag=v0.14 --ember-data

...and committing the files the commands place in `vendor/`
…-5-fix-frontend

fix: ember was broken, and some assets failed to load
@pdl pdl force-pushed the upgrade/rails-6.1.7.6 branch from 0a10df9 to cb21368 Compare March 5, 2024 12:25
pdl added 25 commits March 5, 2024 14:04
https://unep-wcmc.codebasehq.com/projects/species-rails-upgrade/tickets/117

`scientific_name=` was being called before `name_status` was set, which meant
that it always behaved as if `name_status` were the string 'A' during
instantiation, because the setter for `name_status` had not yet been called.

This meant that new synonyms were losing the genus part of the binomial
full name assigned to them, because this is stripped for A-names.
…mview fails

https://unep-wcmc.codebasehq.com/projects/species-rails-upgrade/tickets/139

If a user edits names in change_type so that either ADDITION or DELETION is
missing, then this function will concatenate NULL while building SQL, leading
to a confusing error message.
@pdl pdl merged commit 7b272cf into rails-upgrades Mar 13, 2024
@pdl pdl deleted the upgrade/rails-6.1.7.6 branch March 13, 2024 16:24
@pdl pdl mentioned this pull request Mar 14, 2024
pdl added a commit that referenced this pull request Apr 10, 2024
#974

Upgrades:

- Rails 4.0 to 6.1
- Ruby 2.3 to 3.0
- Many other dependencies, and associated fixes
- See notes in #969 for most of the changes
- Also includes feature change to checklist #972
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants