Add Service

This commit is contained in:
Andras Bacsai
2023-03-28 08:28:03 +02:00
parent f7dd65d1e1
commit f4daffaa89
10 changed files with 114 additions and 27 deletions

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('services', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->string('name');
$table->morphs('destination');
$table->foreignId('environment_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('services');
}
};

View File

@@ -28,7 +28,7 @@ class ApplicationSeeder extends Seeder
]);
Application::create([
'id' => 2,
'name' => 'My Second application',
'name' => 'My second application (Swarm)',
'environment_id' => $environment_1->id,
'destination_id' => $swarm_docker_1->id,
'destination_type' => SwarmDocker::class,

View File

@@ -20,7 +20,5 @@ class DBSeeder extends Seeder
'destination_id' => $standalone_docker_1->id,
'destination_type' => StandaloneDocker::class,
]);
}
}

View File

@@ -23,6 +23,7 @@ class DatabaseSeeder extends Seeder
KubernetesSeeder::class,
ApplicationSeeder::class,
DBSeeder::class,
ServiceSeeder::class,
]);
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace Database\Seeders;
use App\Models\Environment;
use App\Models\Service;
use App\Models\StandaloneDocker;
use Illuminate\Database\Seeder;
class ServiceSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$environment_1 = Environment::find(1);
$standalone_docker_1 = StandaloneDocker::find(1);
Service::create([
'id' => 1,
'name'=> "My first database",
'environment_id' => $environment_1->id,
'destination_id' => $standalone_docker_1->id,
'destination_type' => StandaloneDocker::class,
]);
}
}