diff --git a/database/migrations/2016_06_15_075023_fix_cache_table.php b/database/migrations/2016_06_15_075023_fix_cache_table.php new file mode 100644 index 00000000..c2ef10f1 --- /dev/null +++ b/database/migrations/2016_06_15_075023_fix_cache_table.php @@ -0,0 +1,53 @@ +. + */ + +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Database\Migrations\Migration; + +class FixCacheTable extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + // Wipe the cache table - it's in a corrupt state because + // it allowed duplicate keys to exist until now. + DB::table('cache')->delete(); + + Schema::table('cache', function (Blueprint $table) { + $table->unique('key'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('cache', function (Blueprint $table) { + $table->dropUnique('cache_key_unique'); + }); + } +}