refactor(migrations): use explicit column name for activity FK#126
Merged
Conversation
Replaces `foreignIdFor(Activity::class)` with `foreignId('activity_id')`
in the streak_histories stub to match the package's established convention
(14 other FK declarations all use the explicit-column form). Schema is
byte-identical for both new and existing installs — `foreignIdFor` derives
the same `activity_id` column name from the model basename. Also removes
the now-unused `Activity` import.
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.
Summary
Normalises the activity foreign key in the
create_streak_histories_tablestub to match the package's establishedforeignId('column_name')convention used by every other FK declaration across the 20 migration stubs.Changes:
$table->foreignIdFor(Activity::class)→$table->foreignId('activity_id')use LevelUp\Experience\Models\Activity;importWhy
This was the only FK declaration in the package's migration stubs using
foreignIdFor(Model::class)— the other 14 all use the explicit-column form. Standardising on a single style makes the stubs easier to read and audit.Backward compatibility
Schema is byte-identical for both new and existing installs:
foreignIdFor(Activity::class)derives the column name asStr::snake(class_basename(Activity::class)) . '_id'→activity_idActivitydoes not overridegetForeignKey()unsignedBigIntegercolumn with the same name and same chained constraintExisting installs already ran this migration; their
streak_histories.activity_idcolumn exists unchanged and Laravel will not re-run it. Fresh installs after this lands produce the same schema as fresh installs today.