From e7ffd1fd148dcb5673ba7c7e18b937071a6544be Mon Sep 17 00:00:00 2001 From: Dasun Tharanga Date: Sat, 20 Apr 2024 10:26:47 +0530 Subject: [PATCH 1/7] feat: use morphs method --- .../2019_05_03_000002_create_subscriptions_table.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/database/migrations/2019_05_03_000002_create_subscriptions_table.php b/database/migrations/2019_05_03_000002_create_subscriptions_table.php index f38ebb8..b8be670 100644 --- a/database/migrations/2019_05_03_000002_create_subscriptions_table.php +++ b/database/migrations/2019_05_03_000002_create_subscriptions_table.php @@ -13,8 +13,7 @@ public function up(): void { Schema::create('subscriptions', function (Blueprint $table) { $table->id(); - $table->foreignId('billable_id'); - $table->string('billable_type'); + $table->morphs('billable'); $table->string('type'); $table->string('paddle_id')->unique(); $table->string('status'); From cca6333623257ba0da20096eefe67d703078fe7e Mon Sep 17 00:00:00 2001 From: Dasun Tharanga Date: Sat, 20 Apr 2024 10:27:55 +0530 Subject: [PATCH 2/7] feat: use morphs method --- .../migrations/2019_05_03_000001_create_customers_table.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/database/migrations/2019_05_03_000001_create_customers_table.php b/database/migrations/2019_05_03_000001_create_customers_table.php index cc15faa..a12d0d5 100644 --- a/database/migrations/2019_05_03_000001_create_customers_table.php +++ b/database/migrations/2019_05_03_000001_create_customers_table.php @@ -13,8 +13,7 @@ public function up(): void { Schema::create('customers', function (Blueprint $table) { $table->id(); - $table->foreignId('billable_id'); - $table->string('billable_type'); + $table->morphs('billable'); $table->string('paddle_id')->unique(); $table->string('name'); $table->string('email'); From b6619ec4b737dcfe6e09334913670f3979fecca6 Mon Sep 17 00:00:00 2001 From: Dasun Tharanga Date: Sat, 20 Apr 2024 10:28:36 +0530 Subject: [PATCH 3/7] feat: use morphs method --- .../2019_05_03_000002_create_subscriptions_table.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/database/migrations/2019_05_03_000002_create_subscriptions_table.php b/database/migrations/2019_05_03_000002_create_subscriptions_table.php index f38ebb8..4ad19a5 100644 --- a/database/migrations/2019_05_03_000002_create_subscriptions_table.php +++ b/database/migrations/2019_05_03_000002_create_subscriptions_table.php @@ -13,8 +13,7 @@ public function up(): void { Schema::create('subscriptions', function (Blueprint $table) { $table->id(); - $table->foreignId('billable_id'); - $table->string('billable_type'); + $table->morps('billable'); $table->string('type'); $table->string('paddle_id')->unique(); $table->string('status'); From 74a37e66ec8d0f890fe5c8e60ba02a7c976b466e Mon Sep 17 00:00:00 2001 From: Dasun Tharanga Date: Sat, 20 Apr 2024 10:29:14 +0530 Subject: [PATCH 4/7] feat: use morphs method --- .../migrations/2019_05_03_000004_create_transactions_table.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/database/migrations/2019_05_03_000004_create_transactions_table.php b/database/migrations/2019_05_03_000004_create_transactions_table.php index 64b2087..ee039df 100644 --- a/database/migrations/2019_05_03_000004_create_transactions_table.php +++ b/database/migrations/2019_05_03_000004_create_transactions_table.php @@ -13,8 +13,7 @@ public function up(): void { Schema::create('transactions', function (Blueprint $table) { $table->id(); - $table->foreignId('billable_id'); - $table->string('billable_type'); + $table->morphs('billable'); $table->string('paddle_id')->unique(); $table->string('paddle_subscription_id')->nullable()->index(); $table->string('invoice_number')->nullable(); From 1664c8844d329cc08ef796621ee70dd9e6126fbb Mon Sep 17 00:00:00 2001 From: Dasun Tharanga Date: Sat, 20 Apr 2024 10:37:15 +0530 Subject: [PATCH 5/7] feat: remove index method --- .../migrations/2019_05_03_000001_create_customers_table.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/database/migrations/2019_05_03_000001_create_customers_table.php b/database/migrations/2019_05_03_000001_create_customers_table.php index a12d0d5..de58b56 100644 --- a/database/migrations/2019_05_03_000001_create_customers_table.php +++ b/database/migrations/2019_05_03_000001_create_customers_table.php @@ -19,8 +19,6 @@ public function up(): void $table->string('email'); $table->timestamp('trial_ends_at')->nullable(); $table->timestamps(); - - $table->index(['billable_id', 'billable_type']); }); } From 302f3444926c6740c348bce6dec7afe195e486a6 Mon Sep 17 00:00:00 2001 From: Dasun Tharanga Date: Sat, 20 Apr 2024 10:37:43 +0530 Subject: [PATCH 6/7] feat: remove index method --- .../migrations/2019_05_03_000002_create_subscriptions_table.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/database/migrations/2019_05_03_000002_create_subscriptions_table.php b/database/migrations/2019_05_03_000002_create_subscriptions_table.php index b8be670..3384260 100644 --- a/database/migrations/2019_05_03_000002_create_subscriptions_table.php +++ b/database/migrations/2019_05_03_000002_create_subscriptions_table.php @@ -21,8 +21,6 @@ public function up(): void $table->timestamp('paused_at')->nullable(); $table->timestamp('ends_at')->nullable(); $table->timestamps(); - - $table->index(['billable_id', 'billable_type']); }); } From edca721dd97eb7e808f041b0d15d39161c1bce80 Mon Sep 17 00:00:00 2001 From: Dasun Tharanga Date: Sat, 20 Apr 2024 10:38:06 +0530 Subject: [PATCH 7/7] feat: remove index method --- .../migrations/2019_05_03_000004_create_transactions_table.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/database/migrations/2019_05_03_000004_create_transactions_table.php b/database/migrations/2019_05_03_000004_create_transactions_table.php index ee039df..475d5d6 100644 --- a/database/migrations/2019_05_03_000004_create_transactions_table.php +++ b/database/migrations/2019_05_03_000004_create_transactions_table.php @@ -23,8 +23,6 @@ public function up(): void $table->string('currency', 3); $table->timestamp('billed_at'); $table->timestamps(); - - $table->index(['billable_id', 'billable_type']); }); }