Issue/329 refactor seeding (#337)
* Fix Contracts class names * Refactoring of the file seeds so it's not a mess * StyleCI fixes
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Migration;
|
||||
use App\Services\Installer\MigrationService;
|
||||
use App\Services\Installer\SeederService;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateSettingsTable extends Migration
|
||||
{
|
||||
private $migrationSvc;
|
||||
private $seederSvc;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->migrationSvc = new MigrationService();
|
||||
$this->seederSvc = app(SeederService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,7 @@ class CreateSettingsTable extends Migration
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
$this->migrationSvc->syncAllSettings();
|
||||
$this->seederSvc->syncAllSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,21 +28,6 @@ class CreateRanksTable extends Migration
|
||||
|
||||
$table->unique('name');
|
||||
});
|
||||
|
||||
/**
|
||||
* Initial required data...
|
||||
*/
|
||||
$ranks = [
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => 'New Pilot',
|
||||
'hours' => 0,
|
||||
'acars_base_pay_rate' => 50,
|
||||
'manual_base_pay_rate' => 25,
|
||||
],
|
||||
];
|
||||
|
||||
$this->addData('ranks', $ranks);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
<?php
|
||||
|
||||
use App\Services\DatabaseService;
|
||||
use App\Services\Installer\SeederService;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
private static $seed_mapper = [
|
||||
'local' => 'dev',
|
||||
'qa' => 'dev',
|
||||
'staging' => 'dev',
|
||||
];
|
||||
private $seederService;
|
||||
|
||||
private static $always_seed = [
|
||||
'permissions',
|
||||
];
|
||||
public function __construct()
|
||||
{
|
||||
$this->seederService = app(SeederService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the database seeds.
|
||||
@@ -22,28 +19,6 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$env = App::environment();
|
||||
if (array_key_exists($env, self::$seed_mapper)) {
|
||||
$env = self::$seed_mapper[$env];
|
||||
}
|
||||
|
||||
Log::info('Seeding from environment '.$env);
|
||||
$path = database_path('seeds/'.$env.'.yml');
|
||||
|
||||
if (!file_exists($path)) {
|
||||
$path = database_path('seeds/prod.yml');
|
||||
}
|
||||
|
||||
$svc = app(DatabaseService::class);
|
||||
$svc->seed_from_yaml_file($path);
|
||||
|
||||
// Always seed/sync these
|
||||
foreach (self::$always_seed as $file) {
|
||||
Log::info('Importing '.$file);
|
||||
$path = database_path('seeds/'.$file.'.yml');
|
||||
if (file_exists($path)) {
|
||||
$svc->seed_from_yaml_file($path);
|
||||
}
|
||||
}
|
||||
$this->seederService->syncAllSeeds();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
acars:
|
||||
- id: acars_1
|
||||
pirep_id: pirepid_1
|
||||
type: 1
|
||||
nav_type: 2
|
||||
name: TNV
|
||||
lat: 30.28852
|
||||
lon: -96.058239
|
||||
created_at: now
|
||||
updated_at: now
|
||||
- id: acars_2
|
||||
pirep_id: pirepid_1
|
||||
type: 1
|
||||
nav_type: 2
|
||||
name: IAH
|
||||
lat: 29.95691
|
||||
lon: -95.345719
|
||||
created_at: now
|
||||
updated_at: now
|
||||
- id: acars_3
|
||||
pirep_id: pirepid_1
|
||||
type: 1
|
||||
nav_type: 2
|
||||
name: LCH
|
||||
lat: 30.14151
|
||||
lon: -93.105569
|
||||
created_at: now
|
||||
updated_at: now
|
||||
- id: acars_4
|
||||
pirep_id: pirepid_1
|
||||
type: 1
|
||||
nav_type: 2
|
||||
name: MEI
|
||||
lat: 32.37843
|
||||
lon: -88.804267
|
||||
created_at: now
|
||||
updated_at: now
|
||||
- id: acars_5
|
||||
pirep_id: pirepid_1
|
||||
type: 1
|
||||
nav_type: 2
|
||||
name: ATL
|
||||
lat: 33.62907
|
||||
lon: -84.435064
|
||||
created_at: now
|
||||
updated_at: now
|
||||
- id: acars_6
|
||||
pirep_id: pirepid_1
|
||||
type: 1
|
||||
nav_type: 2
|
||||
name: SIE
|
||||
lat: 39.0955
|
||||
lon: -74.800344
|
||||
created_at: now
|
||||
updated_at: now
|
||||
57
app/Database/seeds/dev/acars.yml
Normal file
57
app/Database/seeds/dev/acars.yml
Normal file
@@ -0,0 +1,57 @@
|
||||
acars:
|
||||
id_column: id
|
||||
data:
|
||||
- id: acars_1
|
||||
pirep_id: pirepid_1
|
||||
type: 1
|
||||
nav_type: 2
|
||||
name: TNV
|
||||
lat: 30.28852
|
||||
lon: -96.058239
|
||||
created_at: now
|
||||
updated_at: now
|
||||
- id: acars_2
|
||||
pirep_id: pirepid_1
|
||||
type: 1
|
||||
nav_type: 2
|
||||
name: IAH
|
||||
lat: 29.95691
|
||||
lon: -95.345719
|
||||
created_at: now
|
||||
updated_at: now
|
||||
- id: acars_3
|
||||
pirep_id: pirepid_1
|
||||
type: 1
|
||||
nav_type: 2
|
||||
name: LCH
|
||||
lat: 30.14151
|
||||
lon: -93.105569
|
||||
created_at: now
|
||||
updated_at: now
|
||||
- id: acars_4
|
||||
pirep_id: pirepid_1
|
||||
type: 1
|
||||
nav_type: 2
|
||||
name: MEI
|
||||
lat: 32.37843
|
||||
lon: -88.804267
|
||||
created_at: now
|
||||
updated_at: now
|
||||
- id: acars_5
|
||||
pirep_id: pirepid_1
|
||||
type: 1
|
||||
nav_type: 2
|
||||
name: ATL
|
||||
lat: 33.62907
|
||||
lon: -84.435064
|
||||
created_at: now
|
||||
updated_at: now
|
||||
- id: acars_6
|
||||
pirep_id: pirepid_1
|
||||
type: 1
|
||||
nav_type: 2
|
||||
name: SIE
|
||||
lat: 39.0955
|
||||
lon: -74.800344
|
||||
created_at: now
|
||||
updated_at: now
|
||||
26
app/Database/seeds/dev/ranks.yml
Normal file
26
app/Database/seeds/dev/ranks.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
ranks:
|
||||
- id: 1
|
||||
name: New Pilot
|
||||
hours: 0
|
||||
acars_base_pay_rate: 50
|
||||
manual_base_pay_rate: 25
|
||||
- id: 2
|
||||
name: Junior First Officer
|
||||
hours: 10
|
||||
acars_base_pay_rate: 100
|
||||
manual_base_pay_rate: 90
|
||||
- id: 3
|
||||
name: First Officer
|
||||
hours: 15
|
||||
acars_base_pay_rate: 250
|
||||
manual_base_pay_rate: 200
|
||||
auto_approve_acars: 1
|
||||
auto_approve_manual: 1
|
||||
- id: 4
|
||||
name: Senior Captain
|
||||
hours: 20
|
||||
acars_base_pay_rate: 500
|
||||
manual_base_pay_rate: 400
|
||||
auto_approve_acars: 1
|
||||
auto_approve_manual: 1
|
||||
auto_promote: 0
|
||||
@@ -1,17 +1,19 @@
|
||||
|
||||
airlines:
|
||||
- id: 1
|
||||
icao: VMS
|
||||
iata: VM
|
||||
name: phpvms airlines
|
||||
country: us
|
||||
active: 1
|
||||
created_at: now
|
||||
updated_at: now
|
||||
#airlines:
|
||||
# - id: 1
|
||||
# icao: VMS
|
||||
# iata: VM
|
||||
# name: phpvms airlines
|
||||
# country: us
|
||||
# active: 1
|
||||
# created_at: now
|
||||
# updated_at: now
|
||||
|
||||
roles:
|
||||
- name: fleet-only
|
||||
display_name: Edit Fleet
|
||||
id_column: name
|
||||
data:
|
||||
- name: fleet-only
|
||||
display_name: Edit Fleet
|
||||
|
||||
users:
|
||||
- id: 1
|
||||
@@ -83,29 +85,6 @@ role_user:
|
||||
role_id: 2
|
||||
user_type: App\Models\User
|
||||
|
||||
# ranks
|
||||
ranks:
|
||||
- id: 2
|
||||
name: Junior First Officer
|
||||
hours: 10
|
||||
acars_base_pay_rate: 100
|
||||
manual_base_pay_rate: 90
|
||||
- id: 3
|
||||
name: First Officer
|
||||
hours: 15
|
||||
acars_base_pay_rate: 250
|
||||
manual_base_pay_rate: 200
|
||||
auto_approve_acars: 1
|
||||
auto_approve_manual: 1
|
||||
- id: 4
|
||||
name: Senior Captain
|
||||
hours: 20
|
||||
acars_base_pay_rate: 500
|
||||
manual_base_pay_rate: 400
|
||||
auto_approve_acars: 1
|
||||
auto_approve_manual: 1
|
||||
auto_promote: 0
|
||||
|
||||
awards:
|
||||
- id: 1
|
||||
name: Pilot 50 flights
|
||||
@@ -1,42 +1,41 @@
|
||||
# All of the different permissions that can be assigned to roles
|
||||
---
|
||||
permissions:
|
||||
- name: admin-access
|
||||
display_name: Admin Access
|
||||
description: Access the admin panel
|
||||
- name: airlines
|
||||
display_name: Airlines
|
||||
description: Create/edit airlines
|
||||
- name: airports
|
||||
display_name: Airports
|
||||
description: Create/edit airports
|
||||
- name: addons
|
||||
display_name: Addons
|
||||
description: Edit/view addons
|
||||
- name: awards
|
||||
display_name: Awards
|
||||
description: Create/edit award classes
|
||||
- name: flights
|
||||
display_name: Flights
|
||||
description: Create/edit flights
|
||||
- name: fleet
|
||||
display_name: Fleet
|
||||
description: Create/edit subfleets and fleets
|
||||
- name: fares
|
||||
display_name: Fares
|
||||
description: Create/edit fares
|
||||
- name: finances
|
||||
display_name: Finances
|
||||
description: Create/view finance related items
|
||||
- name: pireps
|
||||
display_name: PIREPs
|
||||
description: Accept/reject/edit PIREPs
|
||||
- name: ranks
|
||||
display_name: Ranks
|
||||
description: Create/edit ranks
|
||||
- name: users
|
||||
display_name: Users
|
||||
description: Create/edit users
|
||||
- name: settings
|
||||
display_name: Settings
|
||||
description: Edit VA settings
|
||||
- name: admin-access
|
||||
display_name: Admin Access
|
||||
description: Access the admin panel
|
||||
- name: airlines
|
||||
display_name: Airlines
|
||||
description: Create/edit airlines
|
||||
- name: airports
|
||||
display_name: Airports
|
||||
description: Create/edit airports
|
||||
- name: addons
|
||||
display_name: Addons
|
||||
description: Edit/view addons
|
||||
- name: awards
|
||||
display_name: Awards
|
||||
description: Create/edit award classes
|
||||
- name: flights
|
||||
display_name: Flights
|
||||
description: Create/edit flights
|
||||
- name: fleet
|
||||
display_name: Fleet
|
||||
description: Create/edit subfleets and fleets
|
||||
- name: fares
|
||||
display_name: Fares
|
||||
description: Create/edit fares
|
||||
- name: finances
|
||||
display_name: Finances
|
||||
description: Create/view finance related items
|
||||
- name: pireps
|
||||
display_name: PIREPs
|
||||
description: Accept/reject/edit PIREPs
|
||||
- name: ranks
|
||||
display_name: Ranks
|
||||
description: Create/edit ranks
|
||||
- name: users
|
||||
display_name: Users
|
||||
description: Create/edit users
|
||||
- name: settings
|
||||
display_name: Settings
|
||||
description: Edit VA settings
|
||||
|
||||
6
app/Database/seeds/prod/ranks.yml
Normal file
6
app/Database/seeds/prod/ranks.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
ranks:
|
||||
- id: 1
|
||||
name: New Pilot
|
||||
hours: 0
|
||||
acars_base_pay_rate: 50
|
||||
manual_base_pay_rate: 25
|
||||
Reference in New Issue
Block a user