Skip to content

Commit

Permalink
Increase cache key and value size in database cache migration
Browse files Browse the repository at this point in the history
  • Loading branch information
jlevers committed Sep 11, 2024
1 parent 81f52a2 commit 7bdf9d0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}

Expand All @@ -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();
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/SellingPartnerApiServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 7bdf9d0

Please sign in to comment.