Skip to content

Commit

Permalink
move code from migration to seeder
Browse files Browse the repository at this point in the history
  • Loading branch information
pachonjcl committed Apr 15, 2024
1 parent e4a6889 commit a66b7b2
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 46 deletions.
46 changes: 0 additions & 46 deletions database/migrations/2024_03_8_101930_create_code_indicator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,52 +26,6 @@ public function up()
$table->softDeletes();
$table->timestamps();
});
$indicators = [
[
'name' => 'Tree cover (TTC)',
'unit' => 'Percent',
'description' => 'Percent tree cover of each site polygon',
'is_active' => 1
],
[
'name' => 'Tree cover loss',
'unit' => 'Ha',
'description' => 'Tree cover loss in hectares',
'is_active' => 1
],
[
'name' => 'Tree cover loss from fires',
'unit' => 'Ha',
'description' => 'Tree cover loss from fires in hectares',
'is_active' => 1
],
[
'name' => 'Hectares under restoration by WWF ecoregion',
'unit' => 'Ha',
'description' => 'Area value for each ecoregion type',
'is_active' => 1
],
[
'name' => 'Hectares under restoration by intervention type',
'unit' => 'Ha',
'description' => 'Area value for each intervention type',
'is_active' => 1
],
[
'name' => 'Tree count',
'unit' => 'Count',
'description' => 'Tree count number and confidence value',
'is_active' => 1
],
];
$now = now();
foreach ($indicators as $indicator) {
$indicator['uuid'] = Str::uuid();
$indicator['uuid_primary'] = $indicator['uuid'];
$indicator['created_at'] = $now;
$indicator['updated_at'] = $now;
DB::table('code_indicator')->insert($indicator);
}
}

/**
Expand Down
63 changes: 63 additions & 0 deletions database/seeders/CodeIndicator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;

class CodeIndicator extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$indicators = [
[
'name' => 'Tree cover (TTC)',
'unit' => 'Percent',
'description' => 'Percent tree cover of each site polygon',
'is_active' => 1
],
[
'name' => 'Tree cover loss',
'unit' => 'Ha',
'description' => 'Tree cover loss in hectares',
'is_active' => 1
],
[
'name' => 'Tree cover loss from fires',
'unit' => 'Ha',
'description' => 'Tree cover loss from fires in hectares',
'is_active' => 1
],
[
'name' => 'Hectares under restoration by WWF ecoregion',
'unit' => 'Ha',
'description' => 'Area value for each ecoregion type',
'is_active' => 1
],
[
'name' => 'Hectares under restoration by intervention type',
'unit' => 'Ha',
'description' => 'Area value for each intervention type',
'is_active' => 1
],
[
'name' => 'Tree count',
'unit' => 'Count',
'description' => 'Tree count number and confidence value',
'is_active' => 1
],
];
$now = now();
foreach ($indicators as $indicator) {
$indicator['uuid'] = Str::uuid();
$indicator['uuid_primary'] = $indicator['uuid'];
$indicator['created_at'] = $now;
$indicator['updated_at'] = $now;
DB::table('code_indicator')->insert($indicator);
}
}
}

0 comments on commit a66b7b2

Please sign in to comment.