Migrate billing from Paddle to Lemon Squeezy
This commit is contained in:
@@ -34,8 +34,8 @@ return new class extends Migration
|
||||
$table->string('stripe_payment_intent_id')->nullable();
|
||||
$table->string('stripe_customer_id')->nullable();
|
||||
$table->string('stripe_subscription_id')->nullable();
|
||||
$table->string('paddle_checkout_id')->nullable();
|
||||
$table->string('paddle_transaction_id')->nullable();
|
||||
$table->string('lemonsqueezy_checkout_id')->nullable();
|
||||
$table->string('lemonsqueezy_order_id')->nullable();
|
||||
$table->json('provider_metadata')->nullable();
|
||||
|
||||
$table->string('locale', 5)->nullable();
|
||||
@@ -47,8 +47,8 @@ return new class extends Migration
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique('stripe_payment_intent_id');
|
||||
$table->unique('paddle_checkout_id');
|
||||
$table->unique('paddle_transaction_id');
|
||||
$table->unique('lemonsqueezy_checkout_id');
|
||||
$table->unique('lemonsqueezy_order_id');
|
||||
$table->index(['provider', 'status']);
|
||||
$table->index('expires_at');
|
||||
});
|
||||
|
||||
@@ -11,26 +11,26 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasColumn('packages', 'paddle_product_id')) {
|
||||
if (! Schema::hasColumn('packages', 'lemonsqueezy_product_id')) {
|
||||
Schema::table('packages', function (Blueprint $table) {
|
||||
$table->string('paddle_product_id')->nullable()->after('price');
|
||||
$table->string('paddle_price_id')->nullable()->after('paddle_product_id');
|
||||
$table->index('paddle_product_id');
|
||||
$table->index('paddle_price_id');
|
||||
$table->string('lemonsqueezy_product_id')->nullable()->after('price');
|
||||
$table->string('lemonsqueezy_variant_id')->nullable()->after('lemonsqueezy_product_id');
|
||||
$table->index('lemonsqueezy_product_id');
|
||||
$table->index('lemonsqueezy_variant_id');
|
||||
});
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('tenants', 'paddle_customer_id')) {
|
||||
if (! Schema::hasColumn('tenants', 'lemonsqueezy_customer_id')) {
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
$table->string('paddle_customer_id')->nullable()->after('subscription_status');
|
||||
$table->index('paddle_customer_id');
|
||||
$table->string('lemonsqueezy_customer_id')->nullable()->after('subscription_status');
|
||||
$table->index('lemonsqueezy_customer_id');
|
||||
});
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('tenant_packages', 'paddle_subscription_id')) {
|
||||
if (! Schema::hasColumn('tenant_packages', 'lemonsqueezy_subscription_id')) {
|
||||
Schema::table('tenant_packages', function (Blueprint $table) {
|
||||
$table->string('paddle_subscription_id')->nullable()->after('package_id');
|
||||
$table->index('paddle_subscription_id');
|
||||
$table->string('lemonsqueezy_subscription_id')->nullable()->after('package_id');
|
||||
$table->index('lemonsqueezy_subscription_id');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -47,31 +47,31 @@ return new class extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
if (Schema::hasColumn('packages', 'paddle_price_id')) {
|
||||
if (Schema::hasColumn('packages', 'lemonsqueezy_variant_id')) {
|
||||
Schema::table('packages', function (Blueprint $table) {
|
||||
$table->dropIndex('packages_paddle_price_id_index');
|
||||
$table->dropColumn('paddle_price_id');
|
||||
$table->dropIndex('packages_lemonsqueezy_variant_id_index');
|
||||
$table->dropColumn('lemonsqueezy_variant_id');
|
||||
});
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('packages', 'paddle_product_id')) {
|
||||
if (Schema::hasColumn('packages', 'lemonsqueezy_product_id')) {
|
||||
Schema::table('packages', function (Blueprint $table) {
|
||||
$table->dropIndex('packages_paddle_product_id_index');
|
||||
$table->dropColumn('paddle_product_id');
|
||||
$table->dropIndex('packages_lemonsqueezy_product_id_index');
|
||||
$table->dropColumn('lemonsqueezy_product_id');
|
||||
});
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('tenants', 'paddle_customer_id')) {
|
||||
if (Schema::hasColumn('tenants', 'lemonsqueezy_customer_id')) {
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
$table->dropIndex('tenants_paddle_customer_id_index');
|
||||
$table->dropColumn('paddle_customer_id');
|
||||
$table->dropIndex('tenants_lemonsqueezy_customer_id_index');
|
||||
$table->dropColumn('lemonsqueezy_customer_id');
|
||||
});
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('tenant_packages', 'paddle_subscription_id')) {
|
||||
if (Schema::hasColumn('tenant_packages', 'lemonsqueezy_subscription_id')) {
|
||||
Schema::table('tenant_packages', function (Blueprint $table) {
|
||||
$table->dropIndex('tenant_packages_paddle_subscription_id_index');
|
||||
$table->dropColumn('paddle_subscription_id');
|
||||
$table->dropIndex('tenant_packages_lemonsqueezy_subscription_id_index');
|
||||
$table->dropColumn('lemonsqueezy_subscription_id');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -12,15 +12,15 @@ return new class extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('packages', function (Blueprint $table) {
|
||||
$table->string('paddle_sync_status', 50)
|
||||
$table->string('lemonsqueezy_sync_status', 50)
|
||||
->nullable()
|
||||
->after('paddle_price_id');
|
||||
$table->timestamp('paddle_synced_at')
|
||||
->after('lemonsqueezy_variant_id');
|
||||
$table->timestamp('lemonsqueezy_synced_at')
|
||||
->nullable()
|
||||
->after('paddle_sync_status');
|
||||
$table->json('paddle_snapshot')
|
||||
->after('lemonsqueezy_sync_status');
|
||||
$table->json('lemonsqueezy_snapshot')
|
||||
->nullable()
|
||||
->after('paddle_synced_at');
|
||||
->after('lemonsqueezy_synced_at');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ return new class extends Migration
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('packages', function (Blueprint $table) {
|
||||
$table->dropColumn(['paddle_sync_status', 'paddle_synced_at', 'paddle_snapshot']);
|
||||
$table->dropColumn(['lemonsqueezy_sync_status', 'lemonsqueezy_synced_at', 'lemonsqueezy_snapshot']);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -36,10 +36,10 @@ return new class extends Migration
|
||||
$table->timestamp('starts_at')->nullable();
|
||||
$table->timestamp('ends_at')->nullable();
|
||||
|
||||
$table->string('paddle_discount_id')->nullable()->unique();
|
||||
$table->string('paddle_mode', 40)->default('standard');
|
||||
$table->json('paddle_snapshot')->nullable();
|
||||
$table->timestamp('paddle_last_synced_at')->nullable();
|
||||
$table->string('lemonsqueezy_discount_id')->nullable()->unique();
|
||||
$table->string('lemonsqueezy_mode', 40)->default('standard');
|
||||
$table->json('lemonsqueezy_snapshot')->nullable();
|
||||
$table->timestamp('lemonsqueezy_last_synced_at')->nullable();
|
||||
|
||||
$table->foreignIdFor(\App\Models\User::class, 'created_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->foreignIdFor(\App\Models\User::class, 'updated_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
|
||||
@@ -20,7 +20,7 @@ return new class extends Migration
|
||||
$table->foreignIdFor(\App\Models\Tenant::class)->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignIdFor(\App\Models\User::class)->nullable()->constrained()->nullOnDelete();
|
||||
|
||||
$table->string('paddle_transaction_id')->nullable();
|
||||
$table->string('lemonsqueezy_order_id')->nullable();
|
||||
$table->string('status', 40)->default('pending');
|
||||
$table->text('failure_reason')->nullable();
|
||||
|
||||
@@ -33,7 +33,7 @@ return new class extends Migration
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['status', 'redeemed_at']);
|
||||
$table->unique('paddle_transaction_id');
|
||||
$table->unique('lemonsqueezy_order_id');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ return new class extends Migration
|
||||
$table->string('recipient_name')->nullable();
|
||||
$table->string('message', 500)->nullable();
|
||||
|
||||
$table->string('paddle_transaction_id')->nullable()->unique();
|
||||
$table->string('paddle_checkout_id')->nullable()->unique();
|
||||
$table->string('paddle_price_id')->nullable();
|
||||
$table->string('lemonsqueezy_order_id')->nullable()->unique();
|
||||
$table->string('lemonsqueezy_checkout_id')->nullable()->unique();
|
||||
$table->string('lemonsqueezy_variant_id')->nullable();
|
||||
|
||||
$table->foreignIdFor(\App\Models\Coupon::class)->nullable()->constrained()->nullOnDelete();
|
||||
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('packages', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('packages', 'paddle_product_id')) {
|
||||
$table->dropIndex('packages_paddle_product_id_index');
|
||||
$table->dropColumn('paddle_product_id');
|
||||
}
|
||||
if (Schema::hasColumn('packages', 'paddle_price_id')) {
|
||||
$table->dropIndex('packages_paddle_price_id_index');
|
||||
$table->dropColumn('paddle_price_id');
|
||||
}
|
||||
if (Schema::hasColumn('packages', 'paddle_sync_status')) {
|
||||
$table->dropColumn(['paddle_sync_status', 'paddle_synced_at', 'paddle_snapshot']);
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('packages', 'lemonsqueezy_product_id')) {
|
||||
$table->string('lemonsqueezy_product_id')->nullable()->after('price');
|
||||
$table->index('lemonsqueezy_product_id');
|
||||
}
|
||||
if (! Schema::hasColumn('packages', 'lemonsqueezy_variant_id')) {
|
||||
$table->string('lemonsqueezy_variant_id')->nullable()->after('lemonsqueezy_product_id');
|
||||
$table->index('lemonsqueezy_variant_id');
|
||||
}
|
||||
if (! Schema::hasColumn('packages', 'lemonsqueezy_sync_status')) {
|
||||
$table->string('lemonsqueezy_sync_status', 50)->nullable()->after('lemonsqueezy_variant_id');
|
||||
$table->timestamp('lemonsqueezy_synced_at')->nullable()->after('lemonsqueezy_sync_status');
|
||||
$table->json('lemonsqueezy_snapshot')->nullable()->after('lemonsqueezy_synced_at');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('tenants', 'paddle_customer_id')) {
|
||||
$table->dropIndex('tenants_paddle_customer_id_index');
|
||||
$table->dropColumn('paddle_customer_id');
|
||||
}
|
||||
if (! Schema::hasColumn('tenants', 'lemonsqueezy_customer_id')) {
|
||||
$table->string('lemonsqueezy_customer_id')->nullable()->after('subscription_status');
|
||||
$table->index('lemonsqueezy_customer_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('tenant_packages', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('tenant_packages', 'paddle_subscription_id')) {
|
||||
$table->dropIndex('tenant_packages_paddle_subscription_id_index');
|
||||
$table->dropColumn('paddle_subscription_id');
|
||||
}
|
||||
if (! Schema::hasColumn('tenant_packages', 'lemonsqueezy_subscription_id')) {
|
||||
$table->string('lemonsqueezy_subscription_id')->nullable()->after('package_id');
|
||||
$table->index('lemonsqueezy_subscription_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('checkout_sessions', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('checkout_sessions', 'paddle_checkout_id')) {
|
||||
$table->dropUnique('checkout_sessions_paddle_checkout_id_unique');
|
||||
$table->dropColumn('paddle_checkout_id');
|
||||
}
|
||||
if (Schema::hasColumn('checkout_sessions', 'paddle_transaction_id')) {
|
||||
$table->dropUnique('checkout_sessions_paddle_transaction_id_unique');
|
||||
$table->dropColumn('paddle_transaction_id');
|
||||
}
|
||||
if (! Schema::hasColumn('checkout_sessions', 'lemonsqueezy_checkout_id')) {
|
||||
$table->string('lemonsqueezy_checkout_id')->nullable()->after('stripe_subscription_id');
|
||||
$table->unique('lemonsqueezy_checkout_id');
|
||||
}
|
||||
if (! Schema::hasColumn('checkout_sessions', 'lemonsqueezy_order_id')) {
|
||||
$table->string('lemonsqueezy_order_id')->nullable()->after('lemonsqueezy_checkout_id');
|
||||
$table->unique('lemonsqueezy_order_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('coupons', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('coupons', 'paddle_discount_id')) {
|
||||
$table->dropUnique('coupons_paddle_discount_id_unique');
|
||||
$table->dropColumn(['paddle_discount_id', 'paddle_mode', 'paddle_snapshot', 'paddle_last_synced_at']);
|
||||
}
|
||||
if (! Schema::hasColumn('coupons', 'lemonsqueezy_discount_id')) {
|
||||
$table->string('lemonsqueezy_discount_id')->nullable()->unique()->after('ends_at');
|
||||
$table->string('lemonsqueezy_mode', 40)->default('standard')->after('lemonsqueezy_discount_id');
|
||||
$table->json('lemonsqueezy_snapshot')->nullable()->after('lemonsqueezy_mode');
|
||||
$table->timestamp('lemonsqueezy_last_synced_at')->nullable()->after('lemonsqueezy_snapshot');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('coupon_redemptions', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('coupon_redemptions', 'paddle_transaction_id')) {
|
||||
$table->dropUnique('coupon_redemptions_paddle_transaction_id_unique');
|
||||
$table->dropColumn('paddle_transaction_id');
|
||||
}
|
||||
if (! Schema::hasColumn('coupon_redemptions', 'lemonsqueezy_order_id')) {
|
||||
$table->string('lemonsqueezy_order_id')->nullable()->after('user_id');
|
||||
$table->unique('lemonsqueezy_order_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('gift_vouchers', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('gift_vouchers', 'paddle_transaction_id')) {
|
||||
$table->dropUnique('gift_vouchers_paddle_transaction_id_unique');
|
||||
$table->dropColumn('paddle_transaction_id');
|
||||
}
|
||||
if (Schema::hasColumn('gift_vouchers', 'paddle_checkout_id')) {
|
||||
$table->dropUnique('gift_vouchers_paddle_checkout_id_unique');
|
||||
$table->dropColumn('paddle_checkout_id');
|
||||
}
|
||||
if (Schema::hasColumn('gift_vouchers', 'paddle_price_id')) {
|
||||
$table->dropColumn('paddle_price_id');
|
||||
}
|
||||
if (! Schema::hasColumn('gift_vouchers', 'lemonsqueezy_order_id')) {
|
||||
$table->string('lemonsqueezy_order_id')->nullable()->unique()->after('message');
|
||||
$table->string('lemonsqueezy_checkout_id')->nullable()->unique()->after('lemonsqueezy_order_id');
|
||||
$table->string('lemonsqueezy_variant_id')->nullable()->after('lemonsqueezy_checkout_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('package_addons', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('package_addons', 'price_id')) {
|
||||
$table->dropColumn('price_id');
|
||||
}
|
||||
if (! Schema::hasColumn('package_addons', 'variant_id')) {
|
||||
$table->string('variant_id')->nullable()->after('label');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('event_package_addons', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('event_package_addons', 'price_id')) {
|
||||
$table->dropColumn('price_id');
|
||||
}
|
||||
if (! Schema::hasColumn('event_package_addons', 'variant_id')) {
|
||||
$table->string('variant_id')->nullable()->after('extra_gallery_days');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('packages', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('packages', 'lemonsqueezy_product_id')) {
|
||||
$table->dropIndex('packages_lemonsqueezy_product_id_index');
|
||||
$table->dropColumn('lemonsqueezy_product_id');
|
||||
}
|
||||
if (Schema::hasColumn('packages', 'lemonsqueezy_variant_id')) {
|
||||
$table->dropIndex('packages_lemonsqueezy_variant_id_index');
|
||||
$table->dropColumn('lemonsqueezy_variant_id');
|
||||
}
|
||||
if (Schema::hasColumn('packages', 'lemonsqueezy_sync_status')) {
|
||||
$table->dropColumn(['lemonsqueezy_sync_status', 'lemonsqueezy_synced_at', 'lemonsqueezy_snapshot']);
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('tenants', 'lemonsqueezy_customer_id')) {
|
||||
$table->dropIndex('tenants_lemonsqueezy_customer_id_index');
|
||||
$table->dropColumn('lemonsqueezy_customer_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('tenant_packages', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('tenant_packages', 'lemonsqueezy_subscription_id')) {
|
||||
$table->dropIndex('tenant_packages_lemonsqueezy_subscription_id_index');
|
||||
$table->dropColumn('lemonsqueezy_subscription_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('checkout_sessions', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('checkout_sessions', 'lemonsqueezy_checkout_id')) {
|
||||
$table->dropUnique('checkout_sessions_lemonsqueezy_checkout_id_unique');
|
||||
$table->dropColumn('lemonsqueezy_checkout_id');
|
||||
}
|
||||
if (Schema::hasColumn('checkout_sessions', 'lemonsqueezy_order_id')) {
|
||||
$table->dropUnique('checkout_sessions_lemonsqueezy_order_id_unique');
|
||||
$table->dropColumn('lemonsqueezy_order_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('coupons', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('coupons', 'lemonsqueezy_discount_id')) {
|
||||
$table->dropUnique('coupons_lemonsqueezy_discount_id_unique');
|
||||
$table->dropColumn(['lemonsqueezy_discount_id', 'lemonsqueezy_mode', 'lemonsqueezy_snapshot', 'lemonsqueezy_last_synced_at']);
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('coupon_redemptions', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('coupon_redemptions', 'lemonsqueezy_order_id')) {
|
||||
$table->dropUnique('coupon_redemptions_lemonsqueezy_order_id_unique');
|
||||
$table->dropColumn('lemonsqueezy_order_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('gift_vouchers', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('gift_vouchers', 'lemonsqueezy_order_id')) {
|
||||
$table->dropUnique('gift_vouchers_lemonsqueezy_order_id_unique');
|
||||
$table->dropColumn('lemonsqueezy_order_id');
|
||||
}
|
||||
if (Schema::hasColumn('gift_vouchers', 'lemonsqueezy_checkout_id')) {
|
||||
$table->dropUnique('gift_vouchers_lemonsqueezy_checkout_id_unique');
|
||||
$table->dropColumn('lemonsqueezy_checkout_id');
|
||||
}
|
||||
if (Schema::hasColumn('gift_vouchers', 'lemonsqueezy_variant_id')) {
|
||||
$table->dropColumn('lemonsqueezy_variant_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('package_addons', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('package_addons', 'variant_id')) {
|
||||
$table->dropColumn('variant_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('event_package_addons', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('event_package_addons', 'variant_id')) {
|
||||
$table->dropColumn('variant_id');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user