-
Notifications
You must be signed in to change notification settings - Fork 433
Ensure shipping table json fields are set to jsonb #2279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 1.x
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughAdds a PostgreSQL-specific migration that alters shipping_methods.data from JSON to JSONB in up(), with a reversible down() to switch back to JSON. The migration no-ops for non-PostgreSQL drivers and respects the table prefix. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (3)
packages/table-rate-shipping/database/migrations/2025_08_18_100000_switch_shipping_to_jsonb_columns.php (3)
17-19
: Bind Schema operations to the configured Lunar connection.Since Migration::getConnection() overrides the connection, explicitly binding Schema to that connection avoids any ambiguity if the default app connection differs.
Apply this diff:
- Schema::table($this->prefix.'shipping_methods', function (Blueprint $table) { + Schema::connection($this->getConnection())->table($this->prefix.'shipping_methods', function (Blueprint $table) { $table->jsonb('data')->nullable()->change(); });
29-31
: Do the same in down() for consistency.Apply this diff:
- Schema::table($this->prefix.'shipping_methods', function (Blueprint $table) { + Schema::connection($this->getConnection())->table($this->prefix.'shipping_methods', function (Blueprint $table) { $table->json('data')->nullable()->change(); });
17-19
: Optional hardening: guard when table/column is missing.If the addon is installed in an environment where the table doesn’t exist yet (or during partial setup), guarding avoids migration failures.
Minimal guard (assuming you adopt connection binding suggested earlier):
- Schema::connection($this->getConnection())->table($this->prefix.'shipping_methods', function (Blueprint $table) { + $schema = Schema::connection($this->getConnection()); + if (! $schema->hasTable($this->prefix.'shipping_methods') || ! $schema->hasColumn($this->prefix.'shipping_methods', 'data')) { + return; + } + $schema->table($this->prefix.'shipping_methods', function (Blueprint $table) { $table->jsonb('data')->nullable()->change(); });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
packages/table-rate-shipping/database/migrations/2025_08_18_100000_switch_shipping_to_jsonb_columns.php
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/table-rate-shipping/database/migrations/2025_08_18_100000_switch_shipping_to_jsonb_columns.php (2)
packages/core/src/Facades/DB.php (1)
DB
(116-128)packages/core/src/Base/Migration.php (1)
Migration
(7-38)
⏰ 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: search - PHP 8.4 - L12.* ↑
- GitHub Check: core - PHP 8.4 - L12.* ↑
- GitHub Check: stripe - PHP 8.4 - L12.* ↑
- GitHub Check: shipping - PHP 8.4 - L12.* ↑ E
- GitHub Check: shipping - PHP 8.4 - L12.* ↑
- GitHub Check: search - PHP 8.4 - L11.* ↑ E
- GitHub Check: admin - PHP 8.4 - L12.* ↑
- GitHub Check: admin - PHP 8.4 - L12.* ↑ E
- GitHub Check: core - PHP 8.4 - L12.* ↑ E
- GitHub Check: core - PHP 8.4 - L11.* ↑ E
- GitHub Check: admin - PHP 8.4 - L11.* ↑
- GitHub Check: core - PHP 8.4 - L11.* ↑
- GitHub Check: admin - PHP 8.3 - L12.* ↑
- GitHub Check: core - PHP 8.3 - L12.* ↑ E
- GitHub Check: core - PHP 8.3 - L12.* ↑
- GitHub Check: admin - PHP 8.3 - L12.* ↑ E
- GitHub Check: admin - PHP 8.3 - L11.* ↑
- GitHub Check: core - PHP 8.3 - L11.* ↑ E
- GitHub Check: admin - PHP 8.3 - L11.* ↑ E
- GitHub Check: core - PHP 8.3 - L11.* ↑
🔇 Additional comments (3)
packages/table-rate-shipping/database/migrations/2025_08_18_100000_switch_shipping_to_jsonb_columns.php (3)
10-20
: Dependency check passed: doctrine/dbal is already required
Thecomposer.json
showsdoctrine/dbal
(version ^3.6) in the mainrequire
section, so the->change()
call on thejsonb
column will work as intended. No further action needed.
18-18
: shipping_methods.data column remains nullableThe original migration (
2022_04_28_110000_create_shipping_methods_table.php:19
) defines thedata
column as$table->json('data')->nullable();The new migration switches its type to
jsonb
and still applies->nullable()
, so nullability is unchanged. No schema adjustment is needed here.
17-19
: Verification Complete: Only one JSON column present
I searched the table-rate-shipping migrations and package code and found no other->json
/->jsonb
columns—shipping_methods.data
is the sole JSON field. This migration covers all JSON columns in the addon, so no further changes are required.
...ble-rate-shipping/database/migrations/2025_08_18_100000_switch_shipping_to_jsonb_columns.php
Show resolved
Hide resolved
...ble-rate-shipping/database/migrations/2025_08_18_100000_switch_shipping_to_jsonb_columns.php
Show resolved
Hide resolved
@alecritson thanks! Saved me a job. |
#2278 Removed the
jsonb
changes from shipping tables but didn't reapply them via the shipping addon. This PR mimics the core migration but within the shipping addon.Summary by CodeRabbit