Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Rails 7 #3

Merged
merged 7 commits into from
Jan 3, 2024
Merged

Upgrade to Rails 7 #3

merged 7 commits into from
Jan 3, 2024

Conversation

stefannibrasil
Copy link

This is one of the dependencies we need to upgrade to Rails 7 first before upgrading the main CK's app.

The major changes are:

  • removal of deprecated active_record.legacy_connection_handling. This was deprecated in 7.0 and removed in 7.1. This config no longer has effects since multiple databases config in Rails has to be configured manually. It is now set to false by default on new rails apps.
  • fixture_path has been renamed to fixture_paths because it's an array that accepts multiples paths.

The other file changes are made so the gem is running on Rails 7.1.2.

Stefanni Brasil added 6 commits December 26, 2023 14:35
From Rails guides:
https://guides.rubyonrails.org/configuring.html#versioned-default-values

config.load_defaults loads default configuration values for a target
version and all versions prior. With this commit, config.load_defaults 7.1
will load defaults for all versions up to and including version 7.1.
With Rails 7.1.2, configuring `fixture_path` has been deprecated in
favor of using an aray of `fixture_paths`.
This was deprecated in 7.0 and removed in 7.1. This config no longer has
effects since multiple databases config in Rails has to be configured
manually. It is now set to false by default.
since rails/rails#42445, this method has been
changed from cattr_accessor to attr_accessor in ActiveRecord.
otherwise, we can't upgrade this gem on the main app ;)
impressionist.gemspec Outdated Show resolved Hide resolved
These changes allow us to support Rails 7.1, so we can remove the
second constraint completely. Otherwise, when we upgrade it to > 7.1,
we will need to update the version again.
@@ -7,7 +7,7 @@ class ImpressionistGenerator < Rails::Generators::Base
# FIX, why is this implementing rails behaviour?
def self.next_migration_number(dirname)
sleep 1
if ActiveRecord::Base.timestamped_migrations
if ActiveRecord.timestamped_migrations

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% if this change is supported in Rails 6.1? Either way I don't think we use this generator, but in case its important:

> ActiveRecord.timestamped_migrations
(irb):1:in `<main>': undefined method `timestamped_migrations' for ActiveRecord:Module (NoMethodError)
 > ActiveRecord::Base.timestamped_migrations
=> true

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, considering that we only use it for the landing pages and not for anything else, I wouldn't worry about the generators. This gem is probably gonna be removed right after the upgrade work is done anyway, so I am gonna leave as it is 👍 thank you for raising that, though 💯

We have this in the main app so this file is probably used only when the generator is run for the first time:

https://github.com/ConvertKit/convertkit/blob/main/db/migrate/20130114172639_create_impressions_table.rb

@@ -23,7 +23,7 @@

# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
config.fixture_path = "spec/fixtures"
config.fixture_paths = ["spec/fixtures"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, I believe this may only be supported in newer versions of Rails

> require "rspec/rails"
=> true
> RSpec.configure { |c| c.fixture_paths = ["spec/fixtures"] }
NoMethodError: undefined method `fixture_paths=' for #<RSpec::Core::Configuration:0x00007f9cfc9968d0
Did you mean?  fixture_path=
               fixture_path
               fixture_path?
from (pry):8:in `block in __pry__'
> RSpec.configure { |c| c.fixture_path = "spec/fixtures" }
=> "spec/fixtures"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good call! If this was being used for other things and outside of convertkit, I would take more care of these cases but going with the comment above, let's go with this for now.

Copy link

@keegnotrub keegnotrub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go, for what its worth, I imagine these changes are more a blocker for Rails 7.1 vs Rails 7.0 correct? If so, may want to prioritize changing the git SHA ahead of the Rails 7.1 upgrade instead of the Rails 7.0? Although perhaps this helps to silence some warnings? Either way looks good, thank you!

@stefannibrasil
Copy link
Author

Thanks, @keegnotrub !

If so, may want to prioritize changing the git SHA ahead of the Rails 7.1 upgrade instead of the Rails 7.0?

I've read this a couple of times and still can't follow, sorry 🙈 could you describe it a bit more, please?

@keegnotrub
Copy link

Apologies, just wondering if we'd necessarily need this updated in order to get to Rails 7.0 (as opposed to Rails 7.1) for the main ckapp repo.

@stefannibrasil
Copy link
Author

Oh, I see what you mean, now, thanks! It was more to have one less thing to be done later than anything else. Also, I tested the changes in staging and the visitors are working, which is the only thing, AFAIK, that we rely on. So if it works, great, right?! 😆

@stefannibrasil stefannibrasil merged commit ece010a into master Jan 3, 2024
2 checks passed
@stefannibrasil stefannibrasil deleted the sb-rails-7 branch January 3, 2024 17:51
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.

2 participants