Refactor ActivityLogModule and clean up seeders
- 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.
This commit is contained in:
29
database/seeders/Migrators/MediaMigrator.php
Normal file
29
database/seeders/Migrators/MediaMigrator.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders\Migrators;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use JsonMachine\Items;
|
||||
|
||||
class MediaMigrator
|
||||
{
|
||||
public function migrate(): void
|
||||
{
|
||||
DB::table('media')->truncate();
|
||||
|
||||
$path = database_path('data/tested/media.json');
|
||||
|
||||
$items = Items::fromFile($path);
|
||||
|
||||
foreach ($items as $id => $item) {
|
||||
if (! $item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
DB::table('media')->insert((array) $item);
|
||||
}
|
||||
|
||||
DB::statement("SELECT setval('media_id_seq', (SELECT MAX(id) from media));");
|
||||
DB::statement("SELECT nextval('media_id_seq');");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user