You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.5 KiB
48 lines
1.5 KiB
<?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
|
|
{
|
|
$connection = config('audit.drivers.database.connection', config('database.default'));
|
|
$table = config('audit.drivers.database.table', 'audits');
|
|
|
|
Schema::connection($connection)->create($table, function (Blueprint $table) {
|
|
|
|
$morphPrefix = config('audit.user.morph_prefix', 'user');
|
|
|
|
$table->bigIncrements('id');
|
|
$table->string($morphPrefix.'_type')->nullable();
|
|
$table->unsignedBigInteger($morphPrefix.'_id')->nullable();
|
|
$table->string('event');
|
|
$table->morphs('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
|
|
{
|
|
$connection = config('audit.drivers.database.connection', config('database.default'));
|
|
$table = config('audit.drivers.database.table', 'audits');
|
|
|
|
Schema::connection($connection)->drop($table);
|
|
}
|
|
};
|
|
|