cache.stub
TLDR
The provided file is a stub file for a migration in the Illuminate\Cache\Console\Stubs namespace. It creates two tables named 'cache' and 'cache_locks' and defines the required columns for each table. The file also includes methods for running the migration and reversing it.
Class Illuminate\Database\Migrations\Migration
This class extends the base Migration class from the Illuminate\Database\Migrations namespace. It serves as the migration class for the stub file.
Method up()
This method is responsible for running the migrations. It creates the 'cache' and 'cache_locks' tables and defines their columns using the Schema facade.
Method down()
This method is responsible for reversing the migrations. It deletes the 'cache' and 'cache_locks' tables using the Schema facade.
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration');
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};