Refactor db migrations
This commit is contained in:
parent
a3353aac0c
commit
04622a9e3b
@ -25,4 +25,21 @@ class DatabaseController extends Controller
|
|||||||
}
|
}
|
||||||
return view('project.database.configuration', ['database' => $database]);
|
return view('project.database.configuration', ['database' => $database]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function backups()
|
||||||
|
{
|
||||||
|
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
||||||
|
if (!$project) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
|
||||||
|
if (!$environment) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
$database = $environment->databases->where('uuid', request()->route('database_uuid'))->first();
|
||||||
|
if (!$database) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
return view('project.database.backups', ['database' => $database]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class ScheduledDatabaseBackup extends Model
|
class ScheduledDatabaseBackup extends BaseModel
|
||||||
{
|
{
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
|
@ -83,4 +83,9 @@ class StandalonePostgresql extends BaseModel
|
|||||||
{
|
{
|
||||||
return $this->morphMany(LocalPersistentVolume::class, 'resource');
|
return $this->morphMany(LocalPersistentVolume::class, 'resource');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scheduledBackups()
|
||||||
|
{
|
||||||
|
return $this->morphMany(ScheduledDatabaseBackup::class, 'database');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ return new class extends Migration {
|
|||||||
$table->string('description')->nullable();
|
$table->string('description')->nullable();
|
||||||
|
|
||||||
$table->string('postgres_user')->default('postgres');
|
$table->string('postgres_user')->default('postgres');
|
||||||
$table->string('postgres_password');
|
$table->text('postgres_password');
|
||||||
$table->string('postgres_db')->default('postgres');
|
$table->string('postgres_db')->default('postgres');
|
||||||
$table->string('postgres_initdb_args')->nullable();
|
$table->string('postgres_initdb_args')->nullable();
|
||||||
$table->string('postgres_host_auth_method')->nullable();
|
$table->string('postgres_host_auth_method')->nullable();
|
||||||
@ -28,6 +28,7 @@ return new class extends Migration {
|
|||||||
$table->string('image')->default('postgres:15-alpine');
|
$table->string('image')->default('postgres:15-alpine');
|
||||||
$table->boolean('is_public')->default(false);
|
$table->boolean('is_public')->default(false);
|
||||||
$table->integer('public_port')->nullable();
|
$table->integer('public_port')->nullable();
|
||||||
|
$table->text('ports_mappings')->nullable();
|
||||||
|
|
||||||
$table->string('limits_memory')->default("0");
|
$table->string('limits_memory')->default("0");
|
||||||
$table->string('limits_memory_swap')->default("0");
|
$table->string('limits_memory_swap')->default("0");
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
return new class extends Migration {
|
|
||||||
public function up(): void
|
|
||||||
{
|
|
||||||
Schema::table('standalone_postgresqls', function (Blueprint $table) {
|
|
||||||
$table->text('ports_mappings')->nullable();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
Schema::table('standalone_postgresqls', function (Blueprint $table) {
|
|
||||||
$table->dropColumn('ports_mappings');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
@ -9,6 +9,7 @@ return new class extends Migration {
|
|||||||
{
|
{
|
||||||
Schema::create('scheduled_database_backups', function (Blueprint $table) {
|
Schema::create('scheduled_database_backups', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
|
$table->string('uuid')->unique();
|
||||||
$table->boolean('enabled')->default(true);
|
$table->boolean('enabled')->default(true);
|
||||||
$table->boolean('keep_locally')->default(true);
|
$table->boolean('keep_locally')->default(true);
|
||||||
$table->string('save_s3')->default(true);
|
$table->string('save_s3')->default(true);
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
return new class extends Migration {
|
|
||||||
public function up(): void
|
|
||||||
{
|
|
||||||
Schema::table('standalone_postgresqls', function (Blueprint $table) {
|
|
||||||
$table->text('postgres_password')->change();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
Schema::table('standalone_postgresqls', function (Blueprint $table) {
|
|
||||||
$table->string('postgres_password')->change();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
@ -3,6 +3,10 @@
|
|||||||
href="{{ route('project.database.configuration', $parameters) }}">
|
href="{{ route('project.database.configuration', $parameters) }}">
|
||||||
<button>Configuration</button>
|
<button>Configuration</button>
|
||||||
</a>
|
</a>
|
||||||
|
<a class="{{ request()->routeIs('project.database.backups') ? 'text-white' : '' }}"
|
||||||
|
href="{{ route('project.database.backups', $parameters) }}">
|
||||||
|
<button>Backups</button>
|
||||||
|
</a>
|
||||||
{{-- <x-applications.links :application="$application" /> --}}
|
{{-- <x-applications.links :application="$application" /> --}}
|
||||||
<div class="flex-1"></div>
|
<div class="flex-1"></div>
|
||||||
{{-- <x-applications.advanced :application="$application" /> --}}
|
{{-- <x-applications.advanced :application="$application" /> --}}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<p>This resource will be deleted. It is not reversible. <br>Please think again.</p>
|
<p>This resource will be deleted. It is not reversible. <br>Please think again.</p>
|
||||||
</x-slot:modalBody>
|
</x-slot:modalBody>
|
||||||
</x-modal>
|
</x-modal>
|
||||||
<h3>Danger Zone</h3>
|
<h2>Danger Zone</h2>
|
||||||
<div class="">Woah. I hope you know what are you doing.</div>
|
<div class="">Woah. I hope you know what are you doing.</div>
|
||||||
<h4 class="pt-4">Delete Resource</h4>
|
<h4 class="pt-4">Delete Resource</h4>
|
||||||
<div class="pb-4">This will stop your containers, delete all related data, etc. Beware! There is no coming
|
<div class="pb-4">This will stop your containers, delete all related data, etc. Beware! There is no coming
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
<h3>Danger Zone</h3>
|
<h2>Danger Zone</h2>
|
||||||
<div class="">Woah. I hope you know what are you doing.</div>
|
<div class="">Woah. I hope you know what are you doing.</div>
|
||||||
<h4 class="pt-4">Delete Server</h4>
|
<h4 class="pt-4">Delete Server</h4>
|
||||||
<div class="pb-4">This will remove this server from Coolify. Beware! There is no coming
|
<div class="pb-4">This will remove this server from Coolify. Beware! There is no coming
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<p>This team be deleted. It is not reversible. <br>Please think again.</p>
|
<p>This team be deleted. It is not reversible. <br>Please think again.</p>
|
||||||
</x-slot:modalBody>
|
</x-slot:modalBody>
|
||||||
</x-modal>
|
</x-modal>
|
||||||
<h3>Danger Zone</h3>
|
<h2>Danger Zone</h2>
|
||||||
<div class="pb-4">Woah. I hope you know what are you doing.</div>
|
<div class="pb-4">Woah. I hope you know what are you doing.</div>
|
||||||
<h4 class="pb-4">Delete Team</h4>
|
<h4 class="pb-4">Delete Team</h4>
|
||||||
@if (session('currentTeam.id') === 0)
|
@if (session('currentTeam.id') === 0)
|
||||||
|
18
resources/views/project/database/backups.blade.php
Normal file
18
resources/views/project/database/backups.blade.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<x-layout>
|
||||||
|
<h1>Backups</h1>
|
||||||
|
<livewire:project.database.heading :database="$database"/>
|
||||||
|
<div class="pt-6">
|
||||||
|
<h2 class="pb-4">Scheduled Backups</h2>
|
||||||
|
<div class="flex flex-wrap gap-2">
|
||||||
|
@forelse($database->scheduledBackups as $backup)
|
||||||
|
<div class="box flex flex-col">
|
||||||
|
<div>Frequency: {{$backup->frequency}}</div>
|
||||||
|
<div>Keep locally: {{$backup->keep_locally}}</div>
|
||||||
|
<div>Sync to S3: {{$backup->save_s3}}</div>
|
||||||
|
</div>
|
||||||
|
@empty
|
||||||
|
<div>No scheduled backups configured.</div>
|
||||||
|
@endforelse
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</x-layout>
|
@ -52,13 +52,18 @@ Route::middleware(['auth'])->group(function () {
|
|||||||
Route::get('/project/{project_uuid}', [ProjectController::class, 'show'])->name('project.show');
|
Route::get('/project/{project_uuid}', [ProjectController::class, 'show'])->name('project.show');
|
||||||
Route::get('/project/{project_uuid}/{environment_name}/new', [ProjectController::class, 'new'])->name('project.resources.new');
|
Route::get('/project/{project_uuid}/{environment_name}/new', [ProjectController::class, 'new'])->name('project.resources.new');
|
||||||
Route::get('/project/{project_uuid}/{environment_name}', [ProjectController::class, 'resources'])->name('project.resources');
|
Route::get('/project/{project_uuid}/{environment_name}', [ProjectController::class, 'resources'])->name('project.resources');
|
||||||
|
|
||||||
|
// Applications
|
||||||
Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}', [ApplicationController::class, 'configuration'])->name('project.application.configuration');
|
Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}', [ApplicationController::class, 'configuration'])->name('project.application.configuration');
|
||||||
Route::get('/project/{project_uuid}/{environment_name}/database/{database_uuid}', [DatabaseController::class, 'configuration'])->name('project.database.configuration');
|
|
||||||
Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment', [ApplicationController::class, 'deployments'])->name('project.application.deployments');
|
Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment', [ApplicationController::class, 'deployments'])->name('project.application.deployments');
|
||||||
Route::get(
|
Route::get(
|
||||||
'/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment/{deployment_uuid}',
|
'/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment/{deployment_uuid}',
|
||||||
[ApplicationController::class, 'deployment']
|
[ApplicationController::class, 'deployment']
|
||||||
)->name('project.application.deployment');
|
)->name('project.application.deployment');
|
||||||
|
|
||||||
|
// Databases
|
||||||
|
Route::get('/project/{project_uuid}/{environment_name}/database/{database_uuid}', [DatabaseController::class, 'configuration'])->name('project.database.configuration');
|
||||||
|
Route::get('/project/{project_uuid}/{environment_name}/database/{database_uuid}/backups', [DatabaseController::class, 'backups'])->name('project.database.backups');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::middleware(['auth'])->group(function () {
|
Route::middleware(['auth'])->group(function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user