This commit is contained in:
Andras Bacsai
2023-03-27 18:14:33 +02:00
parent 653efb6983
commit 7eeaf37873
11 changed files with 43 additions and 55 deletions

View File

@@ -15,9 +15,6 @@ return new class extends Migration
$table->id();
$table->string('uuid')->unique();
$table->string('name')->unique();
$table->nullableMorphs('environments_morph');
$table->foreignId('project_id');
$table->timestamps();
});

View File

@@ -1,30 +0,0 @@
<?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('environmentables', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('environment_id');
$table->unsignedBigInteger('environmentable_id');
$table->string('environmentable_type');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('environmentables');
}
};

View File

@@ -15,7 +15,10 @@ return new class extends Migration
$table->id();
$table->string('uuid')->unique();
$table->string('name');
$table->nullableMorphs('destination');
$table->morphs('destination');
$table->foreignId('environment_id');
$table->timestamps();
});
}

View File

@@ -15,6 +15,10 @@ return new class extends Migration
$table->id();
$table->string('uuid')->unique();
$table->string('name');
$table->morphs('destination');
$table->foreignId('environment_id');
$table->timestamps();
});
}

View File

@@ -3,13 +3,10 @@
namespace Database\Seeders;
use App\Models\Application;
use App\Models\Destination;
use App\Models\Environment;
use App\Models\Project;
use App\Models\StandaloneDocker;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use App\Models\SwarmDocker;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class ApplicationSeeder extends Seeder
{
@@ -20,13 +17,21 @@ class ApplicationSeeder extends Seeder
{
$environment_1 = Environment::find(1);
$standalone_docker_1 = StandaloneDocker::find(1);
$swarm_docker_1 = SwarmDocker::find(1);
$application_1 = Application::create([
Application::create([
'id' => 1,
'name' => 'My first application',
'environment_id' => $environment_1->id,
'destination_id' => $standalone_docker_1->id,
'destination_type' => StandaloneDocker::class,
]);
$environment_1->applications()->attach($application_1);
Application::create([
'id' => 2,
'name' => 'My Second application',
'environment_id' => $environment_1->id,
'destination_id' => $swarm_docker_1->id,
'destination_type' => SwarmDocker::class,
]);
}
}

View File

@@ -4,6 +4,7 @@ namespace Database\Seeders;
use App\Models\Database;
use App\Models\Environment;
use App\Models\StandaloneDocker;
use Illuminate\Database\Seeder;
class DBSeeder extends Seeder
@@ -11,11 +12,15 @@ class DBSeeder extends Seeder
public function run(): void
{
$environment_1 = Environment::find(1);
$database_1 = Database::create([
$standalone_docker_1 = StandaloneDocker::find(1);
Database::create([
'id' => 1,
'name'=> "My first database"
'name'=> "My first database",
'environment_id' => $environment_1->id,
'destination_id' => $standalone_docker_1->id,
'destination_type' => StandaloneDocker::class,
]);
$environment_1->databases()->attach($database_1);
}
}