Added Schema check in Announcements plugin.#132
Conversation
📝 WalkthroughWalkthroughDatabase migration for the announcements table now conditionally creates the table only if it does not exist, preventing duplicate table errors on repeated runs. The schema definition and rollback behavior remain unchanged. ChangesAnnouncements Migration Safety
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@announcements/database/migrations/001_create_announcements_table.php`:
- Line 11: The conditional spacing for the table-check is violating Pint rules;
update the if statement that calls Schema::hasTable('announcements') to follow
Laravel/Pint spacing (e.g. change "if(!Schema::hasTable('announcements')) {" to
"if (! Schema::hasTable('announcements')) {" or the project-preferred variant
"if (!Schema::hasTable('announcements')) {"), modifying the line that contains
Schema::hasTable('announcements') in the migration to match the linter's
expected spacing.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4dae6552-c121-4139-83dc-8ec411102d6d
📒 Files selected for processing (1)
announcements/database/migrations/001_create_announcements_table.php
📜 Review details
🧰 Additional context used
🪛 GitHub Actions: Lint / 3_Pint.txt
announcements/database/migrations/001_create_announcements_table.php
[error] 1-1: Laravel Pint failed: 1 style issue found in the specified file. CI step 'vendor/bin/pint --test' exited with code 1.
🪛 GitHub Actions: Lint / Pint
announcements/database/migrations/001_create_announcements_table.php
[error] 1-1: Laravel Pint (vendor/bin/pint --test) failed: 1 style issue found in this file. CI exited with code 1.
| $table->timestamp('valid_to')->nullable(); | ||
| $table->timestamps(); | ||
| }); | ||
| if(!Schema::hasTable('announcements')) { |
There was a problem hiding this comment.
Fix Pint style violation on the conditional (currently blocking CI).
Line 11 should follow Laravel/Pint spacing conventions; this is likely the single lint failure in the pipeline.
Suggested fix
- if(!Schema::hasTable('announcements')) {
+ if (! Schema::hasTable('announcements')) {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if(!Schema::hasTable('announcements')) { | |
| if (! Schema::hasTable('announcements')) { |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@announcements/database/migrations/001_create_announcements_table.php` at line
11, The conditional spacing for the table-check is violating Pint rules; update
the if statement that calls Schema::hasTable('announcements') to follow
Laravel/Pint spacing (e.g. change "if(!Schema::hasTable('announcements')) {" to
"if (! Schema::hasTable('announcements')) {" or the project-preferred variant
"if (!Schema::hasTable('announcements')) {"), modifying the line that contains
Schema::hasTable('announcements') in the migration to match the linter's
expected spacing.
Updated the Schema for the migration for the Announcements plugin to check whether the table is already loaded into the database. This will prevent errors from cropping up when doing the Auto-Update script.
Summary by CodeRabbit