【Laravel】artisanのcache:tableコマンドを解説

チートシート

Laravel 10.x以降のartisanの「cache:table」コマンドを解説します。

Description

キャッシュデータベーステーブルのマイグレーションを作成します。

Usage

php artisan cache:table

Options

オプションはありません。

Example

no options

php artisan cache:table
   INFO  Migration created successfully.  
<?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');
    }
};

Source

10.x

framework/src/Illuminate/Cache/Console/CacheTableCommand.php at 11.x · laravel/framework
The Laravel Framework. Contribute to laravel/framework development by creating an account on GitHub.

11.x

framework/src/Illuminate/Cache/Console/CacheTableCommand.php at 11.x · laravel/framework
The Laravel Framework. Contribute to laravel/framework development by creating an account on GitHub.

コメント

タイトルとURLをコピーしました