master

laravel/framework

Last updated at: 28/12/2023 01:39

database.stub

TLDR

This file contains a stub for a database migration to create a sessions table in the database.

Classes

Class Illuminate\Session\Console\stubs\database.stub

This class represents a database migration to create a sessions table in the database. It extends the Migration class from the Illuminate\Database\Migrations namespace. The class has two methods:

  • up(): This method is called to run the migrations. It uses the Schema facade to create the sessions table with the necessary columns.
  • down(): This method is called to reverse the migrations. It uses the Schema facade to drop the sessions table.
<?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('sessions', function (Blueprint $table) {
            $table->string('id')->primary();
            $table->foreignId('user_id')->nullable()->index();
            $table->string('ip_address', 45)->nullable();
            $table->text('user_agent')->nullable();
            $table->longText('payload');
            $table->integer('last_activity')->index();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('sessions');
    }
};