49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function up()
|
|
{
|
|
Schema::create('logs', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->unsignedBigInteger('user_id');
|
|
$table->unsignedBigInteger('target_id')->nullable();
|
|
$table->unsignedBigInteger('log_action_id');
|
|
|
|
$table->string('log')->nullable();
|
|
|
|
$table->morphs('loggable');
|
|
|
|
$table->unsignedBigInteger('amount')->nullable();
|
|
|
|
$table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
|
|
$table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
|
|
|
|
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
|
$table->foreign('target_id')->references('id')->on('users')->onDelete('cascade');
|
|
$table->foreign('log_action_id')->references('id')->on('log_actions')->onDelete('cascade');
|
|
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function down()
|
|
{
|
|
Schema::dropIfExists('logs');
|
|
}
|
|
};
|