Skip to content

Commit

Permalink
MPM-6 update database
Browse files Browse the repository at this point in the history
  • Loading branch information
InensusDev committed Feb 7, 2024
1 parent a0f277d commit 575c35f
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 71 deletions.
4 changes: 3 additions & 1 deletion Website/htdocs/mpmanager/app/Models/UsageType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class UsageType extends Model
class UsageType extends MasterModel
{
use HasFactory;

protected $table = 'usage_types';
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
*/
public function up()
{
Schema::connection('micropowermanager')->create('usage_types', function (Blueprint $table) {
Schema::connection('micro_power_manager')->create('usage_types', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('value');
$table->timestamps();
});
}
Expand All @@ -26,6 +28,6 @@ public function up()
*/
public function down()
{
Schema::connection('micropowermanager')->dropIfExists('usage_types');
Schema::connection('micro_power_manager')->dropIfExists('usage_types');
}
};

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
return new class extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::connection('micropowermanager')->table('main_settings', function (Blueprint $table) {
//
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');
});
}

Expand All @@ -25,7 +32,7 @@ public function up()
*/
public function down()
{
Schema::connection('micropowermanager')->table('main_settings', function (Blueprint $table) {
Schema::connection('shard')->table('main_settings', function (Blueprint $table) {
//
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public function run()
{
$this->call(MpmPluginsSeeder::class);
$this->call(ProtectedPagesSeeder::class);
$this->call(UsageTypeSeeder::class);
}
}
33 changes: 32 additions & 1 deletion Website/htdocs/mpmanager/database/seeders/UsageTypeSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Database\Seeders;

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

class UsageTypeSeeder extends Seeder
{
Expand All @@ -13,6 +14,36 @@ class UsageTypeSeeder extends Seeder
*/
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',
]
)
);
}
}

0 comments on commit 575c35f

Please sign in to comment.