feat: configurable table names#122
Open
cjmellor wants to merge 17 commits into
Open
Conversation
All 13 create-table stubs now use config('level-up.tables.<key>') for
Schema::create/dropIfExists, and every constrained() call that points at
a package table passes an explicit table: named argument.
…ferences from config
Also disable phpdoc_type_annotations_only rule in Pint as it was removing documentation comments that aren't type annotations.
The previous commit added an explanatory comment requested in code review, then disabled Pint's phpdoc_type_annotations_only rule (which strips it). The project-wide config change wasn't worth keeping for one comment. Reverts both changes; the timing rationale lives in the spec/plan docs.
belongsToMany and morphedByMany relationships were referencing pivot
tables (achievement_user, challenge_user, multiplier_scopes) by their
default names. They now read from config('level-up.tables.<key>') so
the table_prefix and per-table overrides actually apply.
Affects: HasAchievements, HasChallenges, Achievement, Challenge,
Multiplier. Adds regression coverage in TablePrefixIntegrationTest.
…vements
Folds the duplicated belongsToMany(...)->withPivot('progress') chain
shared by allAchievements(), achievements(), achievementsWithProgress(),
and secretAchievements() into a single private helper.
Seven query fragments in HasChallenges and ChallengeService still
hardcoded the default table names ('challenge_user.completed_at',
'achievements.id', DB::table('challenge_user')) and bypassed the
table-name resolver. Under a prefix or override, this silently
broke activeChallenges/completedChallenges, the achievement_ids
preload, and challenge completion (the raw DB::table UPDATE matched
zero rows, so ChallengeCompleted never fired and rewards were
never dispatched).
Resolve each fragment through config('level-up.tables.*').
Surfaced by a sandbox integration test that exercised every README
operation against five table-naming configurations across SQLite
and MySQL.
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
Resolves #121.
LEVEL_UP_TABLE_PREFIXenv var (and matchingtable_prefixconfig key) that prepends a single prefix to every default package table name.tablesconfig array for per-table renames. Any value left equal to the default receives thetable_prefix; any value you change is taken verbatim and escapes the prefix.'table'config key keeps working as a fallback fortables.experiences.A new "Customizing Table Names" section in the README walks through the three usage patterns (prefix only, per-table override, combining both).