- Adjusted indentation in ActivityLogModule methods for consistency. - Simplified ActivityLogRepository class by removing unnecessary lines. - Updated FillJsonData seeder to streamline the run method. - Modified various Migrator classes to change JSON data paths for testing and added sequence reset statements for better database integrity.
30 lines
694 B
PHP
30 lines
694 B
PHP
<?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);
|
|
}
|
|
|
|
DB::statement("SELECT setval('action_events_id_seq', (SELECT MAX(id) from action_events));");
|
|
DB::statement("SELECT nextval('action_events_id_seq');");
|
|
}
|
|
}
|