Fix Migrations: Don't Use Group Eloquent Model#49
Merged
Conversation
The migration 2024_09_16_093650_inactive_groups is querying the groups table with a deleted_at column that doesn't exist yet. This is a migration ordering issue the model (i.e. current code) uses SoftDeletes but the column hasn't been added at the time this migration runs, its added in the 2026_02_18_000000_add_soft_deletes_to_groups_table migration. As such, we need to update the prior migration to not use the Eloquent model and use the query builder instead. TL;DR The ORM did not match the DB schema during migrations. The fix is to not use ORMs to query the DB during migrations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This popped up after #47. There is an issue if we start from a fresh environment and re-run all migrations.
The migration
2024_09_16_093650_inactive_groupsis querying the groups table with adeleted_atcolumn that doesn't exist yet. This is a migration ordering issue the model (i.e. current code) usesSoftDeletesbut the column hasn't been added at the time this migration runs, its added in the2026_02_18_000000_add_soft_deletes_to_groups_table` migration.As such, we need to update the prior migration to not use the Eloquent model and use the query builder instead.
TL;DR The ORM did not match the DB schema during migrations. The fix is to not use ORMs to query the DB during migrations.
qa_req 0 I applied this change to fix the test cluster instance.