Specialize Rails7 Database setup on Heroku CI #1257
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Part 1: Test Rails 7 on Heroku CI
Added a test for Rails 7 to exercise behavior in #1254. Update the Rails 7 example app to use the released version instead of alpha. Also, I updated the app to be a Heroku CI compatible app (adds app.json):
Add CI tests against Rails 7. Which was needed to test specialization
Part 2: Rails 7 Rake tasks for tests
Background
The Ruby buildpack sets up a Rails app's database for a customer. In Rails there are individual migrations which will add or remove a single table/column/etc. Then there is a "schema" that captures the final result of the whole process. Running individual migrations is fragile and prone to break it's also slow. To speed things up we first apply the saved schema, then we run the migrations.
Rails has two different formats for storing schema. There is a simplified "ruby" format that uses a DSL to describe the schema of the database. This is easy to read and understand but it doesn't support database specific calls (for example a GIN index in postgres cannot be applied to a Mysql database). So before we can apply a schema we have to determine which format of schema the developer wants us to apply.
Both schema formats can live in the app at the same time and they can be switched via a config flag in the app.
We handled that previously by calling these two tasks if they existed:
Otherwise we would fallback on calling:
In Rails 6.1 the tasks used for database setup in our test pack were deprecated. They were removed in Rails 7 https://edgeguides.rubyonrails.org/7_0_release_notes.html. Existing Rails 7 apps still fallback to the
rails runner
method but it is slower and error prone see #1254.Fix
This PR moves to specialize the tasks for Rails7+ to use
db:schema:load
per deprecation instruction:That task will handle the logic for both determining the schema format and applying the schema.
GUS-W-10372684