feat: shared environments

This commit is contained in:
Andras Bacsai
2024-01-23 17:13:23 +01:00
parent abcc004953
commit fb478c79b3
42 changed files with 495 additions and 78 deletions

View File

@@ -0,0 +1,37 @@
<?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('shared_environment_variables', function (Blueprint $table) {
$table->id();
$table->string('key');
$table->string('value')->nullable();
$table->boolean('is_shown_once')->default(false);
$table->enum('type', ['team', 'project', 'environment'])->default('team');
$table->foreignId('team_id')->constrained()->onDelete('cascade');
$table->foreignId('project_id')->nullable()->constrained()->onDelete('cascade');
$table->foreignId('environment_id')->nullable()->constrained()->onDelete('cascade');
$table->unique(['key', 'project_id', 'team_id']);
$table->unique(['key', 'environment_id', 'team_id']);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('shared_environment_variables');
}
};

View File

@@ -18,6 +18,7 @@ class DatabaseSeeder extends Seeder
ProjectSeeder::class,
ProjectSettingSeeder::class,
EnvironmentSeeder::class,
TeamEnvironmentVariableSeeder::class,
StandaloneDockerSeeder::class,
SwarmDockerSeeder::class,
KubernetesSeeder::class,

View File

@@ -0,0 +1,36 @@
<?php
namespace Database\Seeders;
use App\Models\SharedEnvironmentVariable;
use Illuminate\Database\Seeder;
class SharedEnvironmentVariableSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
SharedEnvironmentVariable::create([
'key' => 'NODE_ENV',
'value' => 'team_env',
'type' => 'team',
'team_id' => 0,
]);
SharedEnvironmentVariable::create([
'key' => 'NODE_ENV',
'value' => 'env_env',
'type' => 'environment',
'environment_id' => 1,
'team_id' => 0,
]);
SharedEnvironmentVariable::create([
'key' => 'NODE_ENV',
'value' => 'project_env',
'type' => 'project',
'project_id' => 1,
'team_id' => 0,
]);
}
}