fix: align database schema with model definitions - #107
Conversation
- from 'character_wallet' to 'characters_wallet'
WalkthroughRemoves test DB credentials and pipeline environment defaults, adds Discord/Twitch OAuth env keys for testing, adjusts route-list commands to exclude vendor routes, updates Wallet model/factory and related migrations, and renames several pivot table mappings and a sessions column type. Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as Developer
participant Migrate as Migration runner
participant DB as Database
note right of Dev `#DDFFDD`: New migration + model change
Dev->>Migrate: php artisan migrate
Migrate->>DB: CREATE TABLE characters_wallet (id, balance, character_id UUID FK -> characters, timestamps)
DB-->>Migrate: OK
Migrate-->>Dev: Migration completed
note right of Dev `#FFF0CC`: Wallet model has HasFactory for test data generation
Dev->>Dev: Wallet::factory()->create(...)
Dev->>DB: INSERT INTO characters_wallet ...
DB-->>Dev: OK
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (1)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
app-modules/season/database/migrations/2025_10_30_072203_create_sessions_table.php (1)
9-24: Consider adding adown()method for rollback capability.The migration lacks a
down()method, which prevents rolling back this migration if needed during development or deployment issues.Add the following method to enable rollback:
public function down(): void { Schema::dropIfExists('sessions'); }.env.testing.example (1)
68-76: Consider alphabetizing OAuth environment variables.The static analysis tool suggests reordering these variables alphabetically within their respective groups (Discord and Twitch) for consistency. While this doesn't affect functionality, it improves maintainability.
Apply this reordering:
-DISCORD_OAUTH_CLIENT_ID= -DISCORD_OAUTH_CLIENT_SECRET= -DISCORD_OAUTH_SCOPES= -DISCORD_OAUTH_REDIRECT_URI= +DISCORD_OAUTH_CLIENT_ID= +DISCORD_OAUTH_CLIENT_SECRET= +DISCORD_OAUTH_REDIRECT_URI= +DISCORD_OAUTH_SCOPES= -TWITCH_OAUTH_SCOPES= -TWITCH_OAUTH_CLIENT_ID= -TWITCH_OAUTH_CLIENT_SECRET= -TWITCH_OAUTH_REDIRECT_URI= +TWITCH_OAUTH_CLIENT_ID= +TWITCH_OAUTH_CLIENT_SECRET= +TWITCH_OAUTH_REDIRECT_URI= +TWITCH_OAUTH_SCOPES=app-modules/character/database/migrations/2025_11_18_100010_create_character_wallet_table.php (1)
9-20: Consider adding adown()method for rollback capability.The migration lacks a
down()method, preventing rollback during development or in case of deployment issues.Add the following method:
public function down(): void { Schema::dropIfExists('characters_wallet'); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
.env.example(0 hunks).env.pipeline(0 hunks).env.testing.example(1 hunks)Makefile(1 hunks)Taskfile.yml(1 hunks)app-modules/character/database/factories/WalletFactory.php(1 hunks)app-modules/character/database/migrations/2025_11_18_100010_create_character_wallet_table.php(1 hunks)app-modules/character/src/Models/Wallet.php(2 hunks)app-modules/events/src/Models/Pivot/EventAttend.php(1 hunks)app-modules/season/database/migrations/2025_10_30_072203_create_sessions_table.php(1 hunks)app-modules/sponsors/src/Models/Pivot/SponsorAttend.php(1 hunks)composer.json(1 hunks)
💤 Files with no reviewable changes (2)
- .env.example
- .env.pipeline
🧰 Additional context used
🧬 Code graph analysis (1)
app-modules/character/src/Models/Wallet.php (2)
app-modules/character/src/Models/Character.php (1)
Character(27-119)app-modules/character/database/factories/WalletFactory.php (1)
WalletFactory(14-30)
🪛 dotenv-linter (4.0.0)
.env.testing.example
[warning] 71-71: [UnorderedKey] The DISCORD_OAUTH_REDIRECT_URI key should go before the DISCORD_OAUTH_SCOPES key
(UnorderedKey)
[warning] 74-74: [UnorderedKey] The TWITCH_OAUTH_CLIENT_ID key should go before the TWITCH_OAUTH_SCOPES key
(UnorderedKey)
[warning] 75-75: [UnorderedKey] The TWITCH_OAUTH_CLIENT_SECRET key should go before the TWITCH_OAUTH_SCOPES key
(UnorderedKey)
[warning] 76-76: [UnorderedKey] The TWITCH_OAUTH_REDIRECT_URI key should go before the TWITCH_OAUTH_SCOPES key
(UnorderedKey)
🔇 Additional comments (9)
app-modules/character/database/factories/WalletFactory.php (1)
12-12: Excellent type-safety improvement!Updating the PHPDoc annotation from
Factory<Model>toFactory<Wallet>provides better IDE support and type checking.composer.json (1)
97-97: Good improvement for modular architecture!Extending the
ide-helper:modelscommand to cover bothapp-modules/*/src/Modelsandapp/Modelsensures IDE support for models across the entire modular codebase structure.app-modules/character/src/Models/Wallet.php (2)
7-20: Excellent factory integration with proper type annotations!The addition of
HasFactorytrait with the typed docblock/** @use HasFactory<WalletFactory> */provides excellent IDE support and type safety for factory operations.
21-21: Table name change aligns with the new migration.The table name change from
character_wallettocharacters_walletis consistent with the new migration file2025_11_18_100010_create_character_wallet_table.phpand follows Laravel's pluralization conventions.app-modules/season/database/migrations/2025_10_30_072203_create_sessions_table.php (1)
18-18: No issues found — the change is correct.The users table correctly uses UUID primary keys (
$table->uuid('id')->primary()), confirming that theforeignUuid('user_id')foreign key in the sessions table is properly typed and will not cause constraint failures.app-modules/character/database/migrations/2025_11_18_100010_create_character_wallet_table.php (1)
16-16: No issues found—characters table uses UUID primary keys.The
characterstable migration confirms UUID primary key usage at line 18 ($table->uuid('id')->primary()), making theforeignUuid('character_id')constraint in the new migration correct and consistent.app-modules/events/src/Models/Pivot/EventAttend.php (1)
12-12: The review comment is based on incorrect assumptions.No evidence exists of a table rename from
event_attendtoevents_attendees. The codebase contains no references toevent_attendanywhere, and the migration2025_11_05_192756_create_events_attendees_table.phpcreates theevents_attendeestable from scratch. The model's$tableproperty correctly matches the table name created by the migration. There is no mismatch and no missing migration.Likely an incorrect or invalid review comment.
Makefile (1)
8-9: Excellent: route-list command now filters vendor routes.Adding
--except-vendorkeeps the route listing focused on application routes, reducing noise from third-party packages. This aligns with the Taskfile.yml update and improves the developer experience.Taskfile.yml (1)
17-20: Excellent: route-list task now filters vendor routes.Adding
--except-vendorkeeps the route listing focused on application routes. This change mirrors the Makefile update, ensuring consistent behavior whether developers usemake route-listortask route-list.
This pull request includes several improvements and fixes across configuration, database schema, and code quality. The main focus is on aligning environment files, correcting table names and relationships in models and migrations, and enhancing developer tooling and command usage.
Environment and Configuration Updates:
.env.pipelineisn't used anymore;.env.exampleare also unused;.env.testing.examplefile.Database and Model Corrections:
characters_wallettable with correct schema, ensuring proper relationships and naming conventions;Walletmodel and factory to use the correct table namecharacters_walletand improved factory typing and usage ofHasFactory;EventAttendnow usesevents_attendeesandSponsorAttendusesevents_sponsorsfor consistency with database naming conventions;user_idcolumn in thesessionstable migration to use a UUID foreign key.Developer Tooling and Command Improvements:
route-listcmd in bothMakefileandTaskfile.ymlto ignore vendor routes;ide-helpercomposer script to include models from bothapp-modules/*/src/Modelsandapp/Models, improving IDE support for the codebase.Summary by CodeRabbit
Chores
Database