45 lines
1.4 KiB
PHP
45 lines
1.4 KiB
PHP
<?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('captchas', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->uuid('uuid');
|
|
$table->unsignedBigInteger('captcha_token_id')->index();
|
|
$table->foreign('captcha_token_id')->references('id')->on('captcha_tokens');
|
|
$table->timestamps();
|
|
$table->index('created_at');
|
|
$table->unique(['uuid', 'captcha_token_id']);
|
|
});
|
|
Schema::create('captcha_logs', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->unsignedBigInteger('captcha_id')->index();
|
|
$table->foreign('captcha_id')->references('id')->on('captchas');
|
|
$table->unsignedInteger('type')->index();
|
|
$table->ipAddress('ip')->nullable();
|
|
$table->string('user_agent')->nullable();
|
|
$table->text('referer')->nullable();
|
|
$table->timestamp('created_at')->index();
|
|
$table->index(['captcha_id', 'type']);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('captcha_logs');
|
|
Schema::dropIfExists('captchas');
|
|
}
|
|
};
|