Преглед изворни кода

refactor: add idempotency_key nas tabelas

Gustavo Mantovani пре 1 недеља
родитељ
комит
fd3ec93cd3

+ 12 - 7
app/Models/Client.php

@@ -18,8 +18,10 @@ use Illuminate\Database\Eloquent\SoftDeletes;
  * @property \Illuminate\Support\Carbon|null $deleted_at
  * @property string|null $average_rating
  * @property int $total_services
- * @property string|null $external_customer_id
- * @property string|null $external_customer_code
+ * @property string|null $gateway_customer_id
+ * @property string|null $gateway_customer_code
+ * @property int|null $profile_media_id
+ * @property string|null $idempotency_key
  * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ProviderClientBlock> $blockedByProviders
  * @property-read int|null $blocked_by_providers_count
  * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ClientProviderBlock> $blockedProviders
@@ -39,6 +41,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Client whereExternalCustomerCode($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Client whereExternalCustomerId($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Client whereId($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Client whereIdempotencyKey($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Client whereProfileMediaId($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Client whereTotalServices($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Client whereUpdatedAt($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Client whereUserId($value)
@@ -52,8 +56,9 @@ class Client extends Model
 
     protected $fillable = [
         'document',
-        'external_customer_id',
-        'external_customer_code',
+        'gateway_customer_id',
+        'gateway_customer_code',
+        'idempotency_key',
         'user_id',
         'profile_media_id',
     ];
@@ -111,13 +116,13 @@ class Client extends Model
 
     public function ensureGatewayCode(): string
     {
-        if (! empty($this->external_customer_code)) {
-            return $this->external_customer_code;
+        if (! empty($this->gateway_customer_code)) {
+            return $this->gateway_customer_code;
         }
 
         $code = 'client-'.(string) \Illuminate\Support\Str::uuid();
 
-        $this->forceFill(['external_customer_code' => $code])->save();
+        $this->forceFill(['gateway_customer_code' => $code])->save();
 
         return $code;
     }

+ 3 - 0
app/Models/ClientPaymentMethod.php

@@ -23,6 +23,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
  * @property \Illuminate\Support\Carbon|null $deleted_at
  * @property string|null $token
  * @property string|null $gateway_card_id
+ * @property string|null $idempotency_key
  * @property-read \App\Models\Client $client
  * @method static \Illuminate\Database\Eloquent\Builder<static>|ClientPaymentMethod newModelQuery()
  * @method static \Illuminate\Database\Eloquent\Builder<static>|ClientPaymentMethod newQuery()
@@ -39,6 +40,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
  * @method static \Illuminate\Database\Eloquent\Builder<static>|ClientPaymentMethod whereGatewayCardId($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|ClientPaymentMethod whereHolderName($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|ClientPaymentMethod whereId($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|ClientPaymentMethod whereIdempotencyKey($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|ClientPaymentMethod whereIsActive($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|ClientPaymentMethod whereLastFourDigits($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|ClientPaymentMethod whereToken($value)
@@ -55,6 +57,7 @@ class ClientPaymentMethod extends Model
         'client_id',
         'token',
         'gateway_card_id',
+        'idempotency_key',
         'card_number',
         'holder_name',
         'expiration',

+ 16 - 1
app/Models/DeviceToken.php

@@ -7,11 +7,26 @@ use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
 /**
+ * @property int $id
+ * @property int $user_id
+ * @property string $token
+ * @property string $platform
  * @property PushNotificationTargetEnum $app_type
- * @property-read \App\Models\User|null $user
+ * @property bool $active
+ * @property \Illuminate\Support\Carbon|null $created_at
+ * @property \Illuminate\Support\Carbon|null $updated_at
+ * @property-read \App\Models\User $user
  * @method static \Illuminate\Database\Eloquent\Builder<static>|DeviceToken newModelQuery()
  * @method static \Illuminate\Database\Eloquent\Builder<static>|DeviceToken newQuery()
  * @method static \Illuminate\Database\Eloquent\Builder<static>|DeviceToken query()
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|DeviceToken whereActive($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|DeviceToken whereAppType($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|DeviceToken whereCreatedAt($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|DeviceToken whereId($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|DeviceToken wherePlatform($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|DeviceToken whereToken($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|DeviceToken whereUpdatedAt($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|DeviceToken whereUserId($value)
  * @mixin \Eloquent
  */
 class DeviceToken extends Model

+ 24 - 0
app/Models/Notification.php

@@ -7,11 +7,35 @@ use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\SoftDeletes;
 
 /**
+ * @property int $id
+ * @property string $title
+ * @property string $description
+ * @property string $origin
+ * @property int $origin_id
+ * @property string $type
+ * @property bool $read
+ * @property \Illuminate\Support\Carbon|null $read_at
+ * @property int|null $user_id
+ * @property \Illuminate\Support\Carbon|null $deleted_at
+ * @property \Illuminate\Support\Carbon|null $created_at
+ * @property \Illuminate\Support\Carbon|null $updated_at
  * @property-read \App\Models\User|null $user
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification newModelQuery()
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification newQuery()
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification onlyTrashed()
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification query()
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereCreatedAt($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereDeletedAt($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereDescription($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereId($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereOrigin($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereOriginId($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereRead($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereReadAt($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereTitle($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereType($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereUpdatedAt($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereUserId($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification withTrashed(bool $withTrashed = true)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification withoutTrashed()
  * @mixin \Eloquent

+ 3 - 0
app/Models/Payment.php

@@ -38,6 +38,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
  * @property \Illuminate\Support\Carbon|null $updated_at
  * @property \Illuminate\Support\Carbon|null $deleted_at
  * @property string|null $gateway_code
+ * @property string|null $idempotency_key
  * @property-read \App\Models\Client $client
  * @property-read \App\Models\ClientPaymentMethod|null $clientPaymentMethod
  * @property-read \App\Models\Provider|null $provider
@@ -71,6 +72,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Payment whereGatewayProvider($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Payment whereGrossAmount($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Payment whereId($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Payment whereIdempotencyKey($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Payment whereInstallments($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Payment whereMetadata($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Payment whereNetAmount($value)
@@ -98,6 +100,7 @@ class Payment extends Model
         'client_payment_method_id',
         'gateway_provider',
         'gateway_code',
+        'idempotency_key',
         'gateway_entity_reference',
         'gateway_entity_label',
         'gateway_operation_reference',

+ 6 - 6
app/Models/Provider.php

@@ -28,9 +28,6 @@ use Illuminate\Database\Eloquent\SoftDeletes;
  * @property \Illuminate\Support\Carbon|null $created_at
  * @property \Illuminate\Support\Carbon|null $updated_at
  * @property \Illuminate\Support\Carbon|null $deleted_at
- * @property string|null $selfie_media_base64
- * @property string|null $document_front_media_base64
- * @property string|null $document_back_media_base64
  * @property ApprovalStatusEnum $approval_status
  * @property string|null $recipient_id
  * @property string|null $recipient_name
@@ -44,6 +41,9 @@ use Illuminate\Database\Eloquent\SoftDeletes;
  * @property array<array-key, mixed>|null $recipient_transfer_settings
  * @property array<array-key, mixed>|null $recipient_automatic_anticipation_settings
  * @property array<array-key, mixed>|null $recipient_metadata
+ * @property int|null $document_front_media_id
+ * @property int|null $document_back_media_id
+ * @property string|null $idempotency_key
  * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Address> $addresses
  * @property-read int|null $addresses_count
  * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ClientProviderBlock> $blockedByClients
@@ -69,10 +69,11 @@ use Illuminate\Database\Eloquent\SoftDeletes;
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereDailyPrice8h($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereDeletedAt($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereDocument($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereDocumentBackMediaBase64($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereDocumentFrontMediaBase64($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereDocumentBackMediaId($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereDocumentFrontMediaId($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereDocumentVerified($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereId($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereIdempotencyKey($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereProfileMediaId($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereRecipientAutomaticAnticipationSettings($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereRecipientCode($value)
@@ -87,7 +88,6 @@ use Illuminate\Database\Eloquent\SoftDeletes;
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereRecipientTransferSettings($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereRecipientType($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereRg($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereSelfieMediaBase64($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereSelfieVerified($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereTotalServices($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereUpdatedAt($value)

+ 16 - 1
app/Models/PushNotificationLog.php

@@ -7,11 +7,26 @@ use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
 /**
+ * @property int $id
+ * @property string $label
+ * @property int $user_id
  * @property PushNotificationTargetEnum $target
- * @property-read \App\Models\User|null $user
+ * @property string $category
+ * @property \Illuminate\Support\Carbon $sent_at
+ * @property \Illuminate\Support\Carbon|null $created_at
+ * @property \Illuminate\Support\Carbon|null $updated_at
+ * @property-read \App\Models\User $user
  * @method static \Illuminate\Database\Eloquent\Builder<static>|PushNotificationLog newModelQuery()
  * @method static \Illuminate\Database\Eloquent\Builder<static>|PushNotificationLog newQuery()
  * @method static \Illuminate\Database\Eloquent\Builder<static>|PushNotificationLog query()
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|PushNotificationLog whereCategory($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|PushNotificationLog whereCreatedAt($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|PushNotificationLog whereId($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|PushNotificationLog whereLabel($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|PushNotificationLog whereSentAt($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|PushNotificationLog whereTarget($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|PushNotificationLog whereUpdatedAt($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|PushNotificationLog whereUserId($value)
  * @mixin \Eloquent
  */
 class PushNotificationLog extends Model

+ 14 - 2
app/Models/ReviewMedia.php

@@ -6,11 +6,23 @@ use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
 /**
- * @property-read \App\Models\Media|null $media
- * @property-read \App\Models\Review|null $review
+ * @property int $id
+ * @property int $review_id
+ * @property int $media_id
+ * @property string $origin
+ * @property \Illuminate\Support\Carbon|null $created_at
+ * @property \Illuminate\Support\Carbon|null $updated_at
+ * @property-read \App\Models\Media $media
+ * @property-read \App\Models\Review $review
  * @method static \Illuminate\Database\Eloquent\Builder<static>|ReviewMedia newModelQuery()
  * @method static \Illuminate\Database\Eloquent\Builder<static>|ReviewMedia newQuery()
  * @method static \Illuminate\Database\Eloquent\Builder<static>|ReviewMedia query()
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|ReviewMedia whereCreatedAt($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|ReviewMedia whereId($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|ReviewMedia whereMediaId($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|ReviewMedia whereOrigin($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|ReviewMedia whereReviewId($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|ReviewMedia whereUpdatedAt($value)
  * @mixin \Eloquent
  */
 class ReviewMedia extends Model

+ 2 - 2
app/Models/Schedule.php

@@ -99,8 +99,8 @@ class Schedule extends Model
             'user_id',
             'document',
             'average_rating',
-            'external_customer_id',
-            'external_customer_code',
+            'gateway_customer_id',
+            'gateway_customer_code',
         );
     }
 

+ 9 - 1
app/Services/Pagarme/PagarmeCardService.php

@@ -68,6 +68,14 @@ class PagarmeCardService
 
     private function idempotencyKey(ClientPaymentMethod $paymentMethod): string
     {
-        return "client-payment-method-{$paymentMethod->id}-card";
+        if (! empty($paymentMethod->idempotency_key)) {
+            return $paymentMethod->idempotency_key;
+        }
+
+        $key = 'card-'.(string) \Illuminate\Support\Str::uuid();
+
+        $paymentMethod->forceFill(['idempotency_key' => $key])->save();
+
+        return $key;
     }
 }

+ 15 - 7
app/Services/Pagarme/PagarmeCustomerService.php

@@ -18,8 +18,8 @@ class PagarmeCustomerService
 
     public function createCustomerForClient(Client $client, array $data): ?string
     {
-        if (! empty($client->external_customer_id)) {
-            return $client->external_customer_id;
+        if (! empty($client->gateway_customer_id)) {
+            return $client->gateway_customer_id;
         }
 
         $client->loadMissing('user');
@@ -50,15 +50,15 @@ class PagarmeCustomerService
             method:         'POST',
             path:           '/customers',
             payload:        $customerRequest,
-            idempotencyKey: $this->idempotencyKey($client->id),
+            idempotencyKey: $this->idempotencyKey($client),
             errorMessage:   'Erro ao criar cliente no Pagar.me.',
         ));
 
         $customerId = $customerData->requireId();
 
         $client->forceFill([
-            'external_customer_id'   => $customerId,
-            'external_customer_code' => $code,
+            'gateway_customer_id'   => $customerId,
+            'gateway_customer_code' => $code,
         ])->save();
 
         return $customerId;
@@ -111,8 +111,16 @@ class PagarmeCustomerService
 
     // evita criacao duplicada de customer
 
-    private function idempotencyKey(int $clientId, string $suffix = 'customer'): string
+    private function idempotencyKey(Client $client): string
     {
-        return "client-{$clientId}-{$suffix}";
+        if (! empty($client->idempotency_key)) {
+            return $client->idempotency_key;
+        }
+
+        $key = 'customer-'.(string) \Illuminate\Support\Str::uuid();
+
+        $client->forceFill(['idempotency_key' => $key])->save();
+
+        return $key;
     }
 }

+ 14 - 6
app/Services/Pagarme/PagarmePaymentService.php

@@ -361,10 +361,18 @@ class PagarmePaymentService
 
     private function idempotencyKey(Payment $payment): string
     {
-        return "payment-{$payment->id}-schedule-{$payment->schedule_id}";
+        if (! empty($payment->idempotency_key)) {
+            return $payment->idempotency_key;
+        }
+
+        $key = 'order-'.(string) \Illuminate\Support\Str::uuid();
+
+        $payment->forceFill(['idempotency_key' => $key])->save();
+
+        return $key;
     }
 
-    // salva o external_customer_id do Pagar.me no Client apos criacao de ordem
+    // salva o gateway_customer_id do Pagar.me no Client apos criacao de ordem
 
     private function saveExternalCustomerId(Payment $payment, OrderResponseData $order): void
     {
@@ -383,14 +391,14 @@ class PagarmePaymentService
 
         $updated = false;
 
-        if (! $client->external_customer_id && $customerId) {
-            $client->external_customer_id = $customerId;
+        if (! $client->gateway_customer_id && $customerId) {
+            $client->gateway_customer_id = $customerId;
 
             $updated = true;
         }
 
-        if (! $client->external_customer_code && $customerCode) {
-            $client->external_customer_code = $customerCode;
+        if (! $client->gateway_customer_code && $customerCode) {
+            $client->gateway_customer_code = $customerCode;
 
             $updated = true;
         }

+ 12 - 4
app/Services/Pagarme/PagarmeRecipientService.php

@@ -85,7 +85,7 @@ class PagarmeRecipientService
             method:         'POST',
             path:           '/recipients',
             payload:        $payload,
-            idempotencyKey: $this->idempotencyKey($provider->id),
+            idempotencyKey: $this->idempotencyKey($provider),
             errorMessage:   'Erro ao criar recebedor no Pagar.me.',
         );
 
@@ -138,7 +138,7 @@ class PagarmeRecipientService
             method:         'PATCH',
             path:           "/recipients/{$provider->recipient_id}/default-bank-account",
             payload:        $payload,
-            idempotencyKey: $this->idempotencyKey($provider->id, 'default-bank-account-'.sha1(json_encode($payload->toArray()))),
+            idempotencyKey: $this->idempotencyKey($provider, 'default-bank-account-'.sha1(json_encode($payload->toArray()))),
             errorMessage:   'Erro ao atualizar conta bancaria do recebedor no Pagar.me.',
         );
 
@@ -193,8 +193,16 @@ class PagarmeRecipientService
 
     // evita criacao duplica de recipient
 
-    private function idempotencyKey(int $providerId, string $suffix = 'recipient'): string
+    private function idempotencyKey(Provider $provider, string $suffix = ''): string
     {
-        return "provider-{$providerId}-{$suffix}";
+        $baseKey = $provider->idempotency_key;
+
+        if (empty($baseKey)) {
+            $baseKey = 'recipient-'.(string) \Illuminate\Support\Str::uuid();
+
+            $provider->forceFill(['idempotency_key' => $baseKey])->save();
+        }
+
+        return $suffix ? "{$baseKey}-{$suffix}" : $baseKey;
     }
 }

+ 46 - 0
database/migrations/2026_06_03_163406_add_idempotency_key_to_related_tables.php

@@ -0,0 +1,46 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    public function up(): void
+    {
+        Schema::table('providers', function (Blueprint $table) {
+            $table->string('idempotency_key')->nullable()->after('recipient_code');
+        });
+
+        Schema::table('payments', function (Blueprint $table) {
+            $table->string('idempotency_key')->nullable()->after('gateway_code');
+        });
+
+        Schema::table('clients', function (Blueprint $table) {
+            $table->string('idempotency_key')->nullable()->after('external_customer_code');
+        });
+
+        Schema::table('client_payment_methods', function (Blueprint $table) {
+            $table->string('idempotency_key')->nullable()->after('gateway_card_id');
+        });
+    }
+
+    public function down(): void
+    {
+        Schema::table('providers', function (Blueprint $table) {
+            $table->dropColumn('idempotency_key');
+        });
+
+        Schema::table('payments', function (Blueprint $table) {
+            $table->dropColumn('idempotency_key');
+        });
+
+        Schema::table('clients', function (Blueprint $table) {
+            $table->dropColumn('idempotency_key');
+        });
+
+        Schema::table('client_payment_methods', function (Blueprint $table) {
+            $table->dropColumn('idempotency_key');
+        });
+    }
+};

+ 24 - 0
database/migrations/2026_06_03_163929_rename_external_customer_columns_to_gateway_prefix_on_clients_table.php

@@ -0,0 +1,24 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    public function up(): void
+    {
+        Schema::table('clients', function (Blueprint $table) {
+            $table->renameColumn('external_customer_id', 'gateway_customer_id');
+            $table->renameColumn('external_customer_code', 'gateway_customer_code');
+        });
+    }
+
+    public function down(): void
+    {
+        Schema::table('clients', function (Blueprint $table) {
+            $table->renameColumn('gateway_customer_id', 'external_customer_id');
+            $table->renameColumn('gateway_customer_code', 'external_customer_code');
+        });
+    }
+};