View file database/upgrades/2023_03_10_144655_add_used_at_to_invite.php

File size: 796B
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up(): void
    {
        Schema::table('invite', function (Blueprint $table) {
            $table->integer('used_at')->after('used')->nullable();

            $table->index(['user_id', 'used', 'created_at']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down(): void
    {
        Schema::table('invite', function (Blueprint $table) {
            $table->dropColumn('used_at');

            $table->dropIndex(['user_id', 'used', 'created_at']);
        });
    }
};