diff --git a/README.md b/README.md index c13d816..11ff344 100644 --- a/README.md +++ b/README.md @@ -192,7 +192,7 @@ $api = $creds->vendorConnector()->directFulfillmentShippingV1(); ## Troubleshooting -If you encounter an error like `String data, right truncated: 7 ERROR: value too long for type character varying(255)`, it's probably because you're using Laravel's database cache, which by default has a 255-character limit on cache values. This library has a migration available to fix this: +If you encounter an error like `String data, right truncated: 7 ERROR: value too long for type character varying(255)`, it's probably because you're using Laravel's database cache, which by default has a 255-character limit on cache keys and values. This library has a migration available to fix this: ```bash $ php artisan vendor:publish --tag="spapi-database-cache" diff --git a/database/migrations/2024_09_11_135400_increase_cache_value_size.php b/database/migrations/2024_09_11_135400_increase_cache_key_and_value_size.php similarity index 82% rename from database/migrations/2024_09_11_135400_increase_cache_value_size.php rename to database/migrations/2024_09_11_135400_increase_cache_key_and_value_size.php index ae200cf..2297b1c 100644 --- a/database/migrations/2024_09_11_135400_increase_cache_value_size.php +++ b/database/migrations/2024_09_11_135400_increase_cache_key_and_value_size.php @@ -12,7 +12,8 @@ public function up(): void { Schema::table('cache', function (Blueprint $table) { - $table->string('value', 511)->change(); + $table->string('key', 511)->change(); + $table->string('value', 1023)->change(); }); } @@ -24,6 +25,7 @@ public function down(): void Schema::table('cache', function (Blueprint $table) { // This will throw an error if there are values longer than 255 characters in the cache table, // but if we automatically truncated them there would be silent data loss + $table->string('key', 255)->change(); $table->string('value', 255)->change(); }); } diff --git a/src/SellingPartnerApiServiceProvider.php b/src/SellingPartnerApiServiceProvider.php index 51050a7..98f158f 100644 --- a/src/SellingPartnerApiServiceProvider.php +++ b/src/SellingPartnerApiServiceProvider.php @@ -26,7 +26,7 @@ public function boot(): void "$migrationsDir/$credentialsMigrationFile" => database_path("migrations/$credentialsMigrationFile"), ], 'spapi-multi-seller'); - $dbCacheMigrationFile = '2024_09_11_135400_increase_cache_value_size.php'; + $dbCacheMigrationFile = '2024_09_11_135400_increase_cache_key_and_value_size.php'; $this->publishesMigrations([ "$migrationsDir/$dbCacheMigrationFile" => database_path("migrations/$dbCacheMigrationFile"), ], 'spapi-database-cache');