Skip to content

Ensure deleting attributes takes place on the right connection#2264

Merged
glennjacobs merged 1 commit intolunarphp:1.xfrom
ryanmitchell:fix/ensure-delete-attributes-on-right-connection
Aug 14, 2025
Merged

Ensure deleting attributes takes place on the right connection#2264
glennjacobs merged 1 commit intolunarphp:1.xfrom
ryanmitchell:fix/ensure-delete-attributes-on-right-connection

Conversation

@ryanmitchell
Copy link
Contributor

@ryanmitchell ryanmitchell commented Aug 8, 2025

This PR fixes a bug where attributables deleting would take place on the default database connection, not the one specified for lunar.

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of attribute deletion operations to ensure related data is consistently removed.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 8, 2025

Walkthrough

The transaction management in the static deleting event of the Attribute model was refactored to use a specific database connection instance rather than the DB facade's static methods. The deletion and transaction operations are now performed through a connection object obtained via DB::connection().

Changes

Cohort / File(s) Change Summary
Attribute Model Transaction Refactor
packages/core/src/Models/Attribute.php
Replaced static DB facade transaction methods with instance-based transaction handling using a specific database connection object.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@vercel
Copy link

vercel bot commented Aug 8, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lunar-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 8, 2025 8:06am

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/core/src/Models/Attribute.php (1)

46-49: Note: Transaction only covers pivot cleanup, not the Attribute delete

This transaction commits before the model delete completes, so failures after this point can leave the Attribute row in place with pivots removed. If full atomicity is required, prefer DB-level FK cascades where possible or initiate a higher-level transaction around the delete operation.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60ac49f and 254c840.

📒 Files selected for processing (1)
  • packages/core/src/Models/Attribute.php (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: PHP 8.4 - L^11.0 ↑
  • GitHub Check: PHP 8.3 - L^11.0 ↑
  • GitHub Check: PHP 8.3 - L^12.0 ↑
  • GitHub Check: admin - PHP 8.4 - L12.* ↑ E
  • GitHub Check: admin - PHP 8.4 - L12.* ↑
  • GitHub Check: shipping - PHP 8.4 - L12.* ↑ E
  • GitHub Check: search - PHP 8.3 - L12.* ↑ E
  • GitHub Check: search - PHP 8.4 - L12.* ↑
  • GitHub Check: stripe - PHP 8.4 - L11.* ↑
  • GitHub Check: core - PHP 8.4 - L12.* ↑ E
  • GitHub Check: admin - PHP 8.4 - L11.* ↑
  • GitHub Check: core - PHP 8.3 - L12.* ↑ E
  • GitHub Check: admin - PHP 8.4 - L11.* ↑ E
  • GitHub Check: admin - PHP 8.3 - L11.* ↑ E
  • GitHub Check: admin - PHP 8.3 - L12.* ↑
  • GitHub Check: core - PHP 8.3 - L11.* ↑
  • GitHub Check: admin - PHP 8.3 - L12.* ↑ E
  • GitHub Check: stripe - PHP 8.3 - L11.* ↑ E
  • GitHub Check: core - PHP 8.3 - L11.* ↑ E
  • GitHub Check: admin - PHP 8.3 - L11.* ↑
🔇 Additional comments (1)
packages/core/src/Models/Attribute.php (1)

44-44: Lunar DB facade connection() already uses the Lunar-specific connection
Inspection of packages/core/src/Facades/DB.php shows its connection() override calls

parent::connection(config('lunar.database.connection'));

so DB::connection() without arguments resolves to the configured Lunar database. No code changes are required.

@glennjacobs glennjacobs merged commit 4cdefbf into lunarphp:1.x Aug 14, 2025
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants