Remove activity log migration files and update FillJsonData seeder to include ActionEventsMigrator. Clean up LoanOrdersMigrator comments for clarity.

This commit is contained in:
Mekan1206
2025-12-21 18:57:21 +05:00
parent a9c7ec6b80
commit 515731003c
10 changed files with 156 additions and 74 deletions

View File

@@ -1,27 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateActivityLogTable extends Migration
{
public function up()
{
Schema::connection(config('activitylog.database_connection'))->create(config('activitylog.table_name'), function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('log_name')->nullable();
$table->text('description');
$table->nullableMorphs('subject', 'subject');
$table->nullableMorphs('causer', 'causer');
$table->json('properties')->nullable();
$table->timestamps();
$table->index('log_name');
});
}
public function down()
{
Schema::connection(config('activitylog.database_connection'))->dropIfExists(config('activitylog.table_name'));
}
}

View File

@@ -1,22 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddEventColumnToActivityLogTable extends Migration
{
public function up()
{
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
$table->string('event')->nullable()->after('subject_type');
});
}
public function down()
{
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
$table->dropColumn('event');
});
}
}

View File

@@ -1,22 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddBatchUuidColumnToActivityLogTable extends Migration
{
public function up()
{
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
$table->uuid('batch_uuid')->nullable()->after('properties');
});
}
public function down()
{
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
$table->dropColumn('batch_uuid');
});
}
}

View File

@@ -0,0 +1,47 @@
<?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('action_events', function (Blueprint $table) {
$table->id();
$table->string('batch_id')->nullable();
$table->unsignedBigInteger('user_id')->nullable()->index();
$table->string('name')->index();
$table->string('actionable_type')->nullable()->index();
$table->unsignedBigInteger('actionable_id')->nullable()->index();
$table->string('target_type')->nullable()->index();
$table->unsignedBigInteger('target_id')->nullable()->index();
$table->string('model_type')->nullable()->index();
$table->unsignedBigInteger('model_id')->nullable()->index();
$table->text('fields')->nullable();
$table->string('status')->index()->default('finished');
$table->text('exception')->nullable();
$table->json('original')->nullable();
$table->json('changes')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('action_events');
}
};

View File

@@ -11,7 +11,7 @@ class FillJsonData extends Seeder
*/
public function run(): void
{
$this->seedVisaMasterPaymentOrders();
}
protected function seedUsers(): void
@@ -68,4 +68,9 @@ class FillJsonData extends Seeder
{
(new Migrators\VisaMasterPaymentOrdersMigrator)->migrate();
}
protected function seedActionEvents(): void
{
(new Migrators\ActionEventsMigrator)->migrate();
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Database\Seeders\Migrators;
use Illuminate\Support\Facades\DB;
use JsonMachine\Items;
class ActionEventsMigrator
{
public function migrate(): void
{
DB::table('action_events')->truncate();
$path = database_path('data/tested/action_events.json');
$items = Items::fromFile($path);
foreach ($items as $id => $item) {
if (! $item) {
continue;
}
DB::table('action_events')->insert((array) $item);
}
}
}

View File

@@ -10,8 +10,6 @@ class LoanOrdersMigrator
{
public function migrate(): void
{
// Running on seeder file, may not work.
DB::table('loan_orders')->truncate();
$path = database_path('data/nurmuhammetsdb/loan_orders.json');