feat: init postgresql database

This commit is contained in:
Andras Bacsai
2023-08-07 18:46:40 +02:00
parent 0a040a0531
commit a020bc872d
38 changed files with 430 additions and 66 deletions

View File

@@ -14,7 +14,7 @@ return new class extends Migration
Schema::create('s3_storages', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->string('name')->nullable();
$table->string('name');
$table->longText('description')->nullable();
$table->string('region')->default('us-east-1');
$table->longText('key');

View File

@@ -0,0 +1,42 @@
<?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('postgresqls', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->string('name');
$table->string('description')->nullable();
$table->string('postgres_user')->default('postgres');
$table->string('postgres_password');
$table->string('postgres_db')->default('postgres');
$table->string('postgres_initdb_args')->nullable();
$table->string('postgres_host_auth_method')->nullable();
$table->json('init_scripts')->nullable();
$table->timestamp('started_at')->nullable();
$table->morphs('destination');
$table->foreignId('environment_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('postgresqls');
}
};

View File

@@ -11,15 +11,8 @@ return new class extends Migration
*/
public function up(): void
{
Schema::create('databases', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->string('name');
$table->morphs('destination');
$table->foreignId('environment_id');
$table->timestamps();
Schema::table('applications', function (Blueprint $table) {
$table->string('description')->nullable();
});
}
@@ -28,6 +21,8 @@ return new class extends Migration
*/
public function down(): void
{
Schema::dropIfExists('databases');
Schema::table('applications', function (Blueprint $table) {
$table->dropColumn('description');
});
}
};
};

View File

@@ -19,13 +19,11 @@ class ApplicationSeeder extends Seeder
*/
public function run(): void
{
$environment_1 = Environment::find(1);
$standalone_docker_1 = StandaloneDocker::find(1);
$github_public_source = GithubApp::where('name', 'Public GitHub')->first();
Application::create([
'name' => 'coollabsio/coolify-examples:nodejs-fastify',
'description' => 'NodeJS Fastify Example',
'fqdn' => 'http://foo.com',
'repository_project_id' => 603035348,
'git_repository' => 'coollabsio/coolify-examples',
@@ -33,11 +31,11 @@ class ApplicationSeeder extends Seeder
'build_pack' => 'nixpacks',
'ports_exposes' => '3000',
'ports_mappings' => '3000:3000',
'environment_id' => $environment_1->id,
'destination_id' => $standalone_docker_1->id,
'environment_id' => 1,
'destination_id' => 1,
'destination_type' => StandaloneDocker::class,
'source_id' => $github_public_source->id,
'source_type' => GithubApp::class
]);
}
}
}

View File

@@ -32,6 +32,7 @@ class DatabaseSeeder extends Seeder
EnvironmentVariableSeeder::class,
LocalPersistentVolumeSeeder::class,
S3StorageSeeder::class,
PostgresqlSeeder::class,
]);
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\Postgresql;
use App\Models\StandaloneDocker;
class PostgresqlSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Postgresql::create([
'name' => 'Local PostgreSQL',
'description' => 'Local PostgreSQL for testing',
'postgres_password' => 'postgres',
'environment_id' => 1,
'destination_id' => 1,
'destination_type' => StandaloneDocker::class,
]);
}
}