Skip to content
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

[14.x] Remove unique index from items table #1594

Merged
merged 2 commits into from
Oct 30, 2023
Merged

Conversation

driesvints
Copy link
Member

I stumbled upon an edge case where Stripe created a new subscription item for the same price ID. This means Cashier attempts to insert this while the unique constraint is active. Although it's unlikely this happens often (we only saw this just a couple of times) we shouldn't rely on this index anymore.

I stumbled upon an edge case where Stripe created a new subscription item for the same price ID. This means Cashier attempts to insert this while the unique constraint is active. Although it's unlikely this happens often (we only saw this just a couple of times) we shouldn't rely on this index anymore.
@taylorotwell taylorotwell merged commit afc3422 into 14.x Oct 30, 2023
9 checks passed
@taylorotwell taylorotwell deleted the driesvints-patch-1 branch October 30, 2023 17:51
@shatterproof
Copy link
Contributor

Migration to manually implement this change:

public function up()
{
    Schema::table('subscription_items', function (Blueprint $table) {
        $table->dropUnique(['subscription_id', 'stripe_price']);
        $table->index(['subscription_id', 'stripe_price']);
    });
}

Note that if you upgraded from Cashier 12.x you may need to replace dropUnique(['subscription_id', 'stripe_price']) with dropUnique(['subscription_id', 'stripe_plan']) since the unique index could still be named with the old column.

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.

3 participants