Enhance MigrationController and ShieldSeeder for improved data migration and role management
- Added new migrators: ModelHasRolesMigrator and OnlinePaymentsMigrator to MigrationController. - Introduced a test method in MigrationController to facilitate online payments migration. - Updated ShieldSeeder to include role IDs for better role management and added new roles with specific IDs.
This commit is contained in:
26
database/seeders/Migrators/ModelHasRolesMigrator.php
Normal file
26
database/seeders/Migrators/ModelHasRolesMigrator.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders\Migrators;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class ModelHasRolesMigrator
|
||||
{
|
||||
public function migrate(): void
|
||||
{
|
||||
DB::table('model_has_roles')->truncate();
|
||||
|
||||
$path = database_path('data/tested/model_has_roles.json');
|
||||
|
||||
$rawData = File::json($path);
|
||||
|
||||
foreach ($rawData as $data) {
|
||||
DB::table('model_has_roles')
|
||||
->insert($data);
|
||||
}
|
||||
|
||||
DB::statement("SELECT setval('model_has_roles_id_seq', (SELECT MAX(id) from model_has_roles));");
|
||||
DB::statement("SELECT nextval('model_has_roles_id_seq');");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user