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

Rails 5.2 dual boot #375

Merged
merged 6 commits into from
Oct 23, 2024
Merged

Rails 5.2 dual boot #375

merged 6 commits into from
Oct 23, 2024

Conversation

yuenmichelle1
Copy link
Collaborator

Rails 5.2 dual boot
Other Changes

  • From Rails 5.1 to 5.2, there was a change in db:load_config task which is a task that db:create depends on. db:load_config now depends on the environment, which would load the application (especially our concerns [used in serializers and models eg. TalkSerializer and BooleanCoercian] to load, which would trigger a DB connection that can't be established because the DB does not exist yet (which is why we run db:create to create the db, but b/c of this change to db:load_config, db:create won't work) . This is a known issue in Rails 5.2+ and can be mitigated see: https://stackoverflow.com/questions/72147515/rails-5-2-load-order-breaks-dbcreate which should also reference the Rails PR that introduce this change
  • We update the RakeFile to get db:create and other rake tasks to succeed, in order to get our CI tests and local dev setup still functional.
  • For FDW Models, primary_key must be specified for each model for our specs to run. See: https://gist.github.com/westonganger/79683fad3e4ec3b10105e40d3069a18e

…fig sending new prereqs

CI test workflows and local dev setup requires db:create rake task. However in Rails 5.2, there was an introduction of new behavior of db:load_config (a task within db:create) which causes db:create to fail. (This is a known issue from Rails and behavior introduced after 5.1.7).

To fix, we delete the new environment prerequisite of db:load_config, (db:load_config depending on environment means the app would load with all observers, sphinx indices, concerns etc which trigger a db connection, BUT can't be established because the DB does not exist yet.).

However, just removing the prerequisite, will get db:create to work, but loading schema will stop working because db:load_config needs that prereq and tehrefore we bring it back after db:create, knowing we have a db to connect to.
@yuenmichelle1 yuenmichelle1 marked this pull request as ready for review October 22, 2024 16:13
@yuenmichelle1 yuenmichelle1 requested a review from Tooyosi October 22, 2024 16:14
@yuenmichelle1
Copy link
Collaborator Author

Hey @Tooyosi , Let me know if you have any questions on this review. It's fairly straight forward sans some finagling that needed to be done due to changes from Rails 5.1 -> 5.2.
Best way to test the rake changes is to start with a clean local dev environment and try to run talk-api local dev setup for 5.1 and 5.2 and run specs.

@yuenmichelle1 yuenmichelle1 merged commit cdcdc39 into master Oct 23, 2024
1 of 2 checks passed
@yuenmichelle1 yuenmichelle1 deleted the rails-5.2-dual-boot branch October 31, 2024 13:40
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