44 lines
1.4 KiB
PHP
44 lines
1.4 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Config;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*/
|
|
public function up(): void
|
|
{
|
|
Schema::connection(config('audit.drivers.database.connection', config('database.default')))->create('audits', function (Blueprint $table) {
|
|
|
|
$morphPrefix = Config::get('audit.user.morph_prefix', 'user');
|
|
|
|
$table->bigIncrements('id');
|
|
$table->string($morphPrefix . '_type')->nullable();
|
|
$table->uuid($morphPrefix . '_id')->nullable();
|
|
$table->string('event');
|
|
$table->uuidMorphs('auditable');
|
|
$table->text('old_values')->nullable();
|
|
$table->text('new_values')->nullable();
|
|
$table->text('url')->nullable();
|
|
$table->ipAddress('ip_address')->nullable();
|
|
$table->string('user_agent', 1023)->nullable();
|
|
$table->string('tags')->nullable();
|
|
$table->timestamps();
|
|
|
|
$table->index([$morphPrefix . '_id', $morphPrefix . '_type']);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::connection(config('audit.drivers.database.connection', config('database.default')))->drop('audits');
|
|
}
|
|
};
|