-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MPM-6] Usage types table in base & extend main settings table (#37)
* MPM-6 update database * MPM-6 update database
- Loading branch information
1 parent
af849ca
commit bb334ab
Showing
5 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class UsageType extends MasterModel | ||
{ | ||
use HasFactory; | ||
|
||
protected $table = 'usage_types'; | ||
} |
33 changes: 33 additions & 0 deletions
33
.../htdocs/mpmanager/database/migrations/base/2024_02_07_100345_create_usage_types_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::connection('micro_power_manager')->create('usage_types', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('name'); | ||
$table->string('value'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::connection('micro_power_manager')->dropIfExists('usage_types'); | ||
} | ||
}; |
39 changes: 39 additions & 0 deletions
39
...ions/micropowermanager/2024_02_07_102305_add_usage_type_column_to_main_settings_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration { | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::connection('shard')->table('main_settings', function (Blueprint $table) { | ||
$table->enum('usage_type', [ | ||
'mini-grid', | ||
'shs', | ||
'e-bike', | ||
'mini-grid&shs', | ||
'mini-grid&e-bike', | ||
'shs&e-bike', | ||
'mini-grid&shs&e-bike' | ||
])->default('mini-grid&shs&e-bike')->after('id'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::connection('shard')->table('main_settings', function (Blueprint $table) { | ||
// | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
Website/htdocs/mpmanager/database/seeders/UsageTypeSeeder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace Database\Seeders; | ||
|
||
use Illuminate\Database\Seeder; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
class UsageTypeSeeder extends Seeder | ||
{ | ||
/** | ||
* Run the database seeds. | ||
* | ||
* @return void | ||
*/ | ||
public function run() | ||
{ | ||
DB::connection('micro_power_manager')->table('usage_types')->insert(array( | ||
[ | ||
'name' => 'Mini-Grid', | ||
'value' => 'mini-grid', | ||
], | ||
[ | ||
'name' => 'Solar Home System', | ||
'value' => 'shs', | ||
], | ||
[ | ||
'name' => 'EBike Rental', | ||
'value' => 'e-bike', | ||
], | ||
[ | ||
'name' => 'Mini-Grid & Solar Home System', | ||
'value' => 'mini-grid&shs', | ||
], | ||
[ | ||
'name' => 'Mini-Grid & EBike Rental', | ||
'value' => 'mini-grid&e-bike', | ||
], | ||
[ | ||
'name' => 'Solar Home & EBike Rental', | ||
'value' => 'shs&e-bike', | ||
], | ||
[ | ||
'name' => 'Mini-Grid & Solar Home System & EBike Rental', | ||
'value' => 'mini-grid&shs&e-bike', | ||
] | ||
) | ||
); | ||
} | ||
} |