Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

soft delete models

Andras Bacsai69343f974a14
diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.php
index 96b843876d..12d540aab3 100644
--- a/app/Console/Commands/Init.php
+++ b/app/Console/Commands/Init.php
@@ -115,16 +115,19 @@ class Init extends Command
$applications = Application::all();
foreach ($applications as $application) {
if (!data_get($application, 'environment')) {
- echo 'Application without environment: ' . $application->name . ' deleting\n';
+ echo 'Application without environment: ' . $application->name . ' soft deleting\n';
$application->delete();
+ continue;
}
if (!$application->destination()) {
- echo 'Application without destination: ' . $application->name . ' deleting\n';
+ echo 'Application without destination: ' . $application->name . ' soft deleting\n';
$application->delete();
+ continue;
}
if (!data_get($application, 'destination.server')) {
- echo 'Application without server: ' . $application->name . ' deleting\n';
+ echo 'Application without server: ' . $application->name . ' soft deleting\n';
$application->delete();
+ continue;
}
}
} catch (\Throwable $e) {
@@ -134,16 +137,19 @@ class Init extends Command
$postgresqls = StandalonePostgresql::all();
foreach ($postgresqls as $postgresql) {
if (!data_get($postgresql, 'environment')) {
- echo 'Postgresql without environment: ' . $postgresql->name . ' deleting\n';
+ echo 'Postgresql without environment: ' . $postgresql->name . ' soft deleting\n';
$postgresql->delete();
+ continue;
}
if (!$postgresql->destination()) {
- echo 'Postgresql without destination: ' . $postgresql->name . ' deleting\n';
+ echo 'Postgresql without destination: ' . $postgresql->name . ' soft deleting\n';
$postgresql->delete();
+ continue;
}
if (!data_get($postgresql, 'destination.server')) {
- echo 'Postgresql without server: ' . $postgresql->name . ' deleting\n';
+ echo 'Postgresql without server: ' . $postgresql->name . ' soft deleting\n';
$postgresql->delete();
+ continue;
}
}
} catch (\Throwable $e) {
@@ -153,16 +159,19 @@ class Init extends Command
$redis = StandaloneRedis::all();
foreach ($redis as $redis) {
if (!data_get($redis, 'environment')) {
- echo 'Redis without environment: ' . $redis->name . ' deleting\n';
+ echo 'Redis without environment: ' . $redis->name . ' soft deleting\n';
$redis->delete();
+ continue;
}
if (!$redis->destination()) {
- echo 'Redis without destination: ' . $redis->name . ' deleting\n';
+ echo 'Redis without destination: ' . $redis->name . ' soft deleting\n';
$redis->delete();
+ continue;
}
if (!data_get($redis, 'destination.server')) {
- echo 'Redis without server: ' . $redis->name . ' deleting\n';
+ echo 'Redis without server: ' . $redis->name . ' soft deleting\n';
$redis->delete();
+ continue;
}
}
} catch (\Throwable $e) {
@@ -173,16 +182,19 @@ class Init extends Command
$mongodbs = StandaloneMongodb::all();
foreach ($mongodbs as $mongodb) {
if (!data_get($mongodb, 'environment')) {
- echo 'Mongodb without environment: ' . $mongodb->name . ' deleting\n';
+ echo 'Mongodb without environment: ' . $mongodb->name . ' soft deleting\n';
$mongodb->delete();
+ continue;
}
if (!$mongodb->destination()) {
- echo 'Mongodb without destination: ' . $mongodb->name . ' deleting\n';
+ echo 'Mongodb without destination: ' . $mongodb->name . ' soft deleting\n';
$mongodb->delete();
+ continue;
}
if (!data_get($mongodb, 'destination.server')) {
- echo 'Mongodb without server: ' . $mongodb->name . ' deleting\n';
+ echo 'Mongodb without server: ' . $mongodb->name . ' soft deleting\n';
$mongodb->delete();
+ continue;
}
}
} catch (\Throwable $e) {
@@ -193,16 +205,19 @@ class Init extends Command
$mysqls = StandaloneMysql::all();
foreach ($mysqls as $mysql) {
if (!data_get($mysql, 'environment')) {
- echo 'Mysql without environment: ' . $mysql->name . ' deleting\n';
+ echo 'Mysql without environment: ' . $mysql->name . ' soft deleting\n';
$mysql->delete();
+ continue;
}
if (!$mysql->destination()) {
- echo 'Mysql without destination: ' . $mysql->name . ' deleting\n';
+ echo 'Mysql without destination: ' . $mysql->name . ' soft deleting\n';
$mysql->delete();
+ continue;
}
if (!data_get($mysql, 'destination.server')) {
- echo 'Mysql without server: ' . $mysql->name . ' deleting\n';
+ echo 'Mysql without server: ' . $mysql->name . ' soft deleting\n';
$mysql->delete();
+ continue;
}
}
} catch (\Throwable $e) {
@@ -213,16 +228,19 @@ class Init extends Command
$mariadbs = StandaloneMariadb::all();
foreach ($mariadbs as $mariadb) {
if (!data_get($mariadb, 'environment')) {
- echo 'Mariadb without environment: ' . $mariadb->name . ' deleting\n';
+ echo 'Mariadb without environment: ' . $mariadb->name . ' soft deleting\n';
$mariadb->delete();
+ continue;
}
if (!$mariadb->destination()) {
- echo 'Mariadb without destination: ' . $mariadb->name . ' deleting\n';
+ echo 'Mariadb without destination: ' . $mariadb->name . ' soft deleting\n';
$mariadb->delete();
+ continue;
}
if (!data_get($mariadb, 'destination.server')) {
- echo 'Mariadb without server: ' . $mariadb->name . ' deleting\n';
+ echo 'Mariadb without server: ' . $mariadb->name . ' soft deleting\n';
$mariadb->delete();
+ continue;
}
}
} catch (\Throwable $e) {
@@ -233,16 +251,19 @@ class Init extends Command
$services = Service::all();
foreach ($services as $service) {
if (!data_get($service, 'environment')) {
- echo 'Service without environment: ' . $service->name . ' deleting\n';
+ echo 'Service without environment: ' . $service->name . ' soft deleting\n';
$service->delete();
+ continue;
}
if (!$service->destination()) {
- echo 'Service without destination: ' . $service->name . ' deleting\n';
+ echo 'Service without destination: ' . $service->name . ' soft deleting\n';
$service->delete();
+ continue;
}
if (!data_get($service, 'server')) {
- echo 'Service without server: ' . $service->name . ' deleting\n';
+ echo 'Service without server: ' . $service->name . ' soft deleting\n';
$service->delete();
+ continue;
}
}
} catch (\Throwable $e) {
@@ -252,8 +273,9 @@ class Init extends Command
$serviceApplications = ServiceApplication::all();
foreach ($serviceApplications as $service) {
if (!data_get($service, 'service')) {
- echo 'ServiceApplication without service: ' . $service->name . ' deleting\n';
+ echo 'ServiceApplication without service: ' . $service->name . ' soft deleting\n';
$service->delete();
+ continue;
}
}
} catch (\Throwable $e) {
@@ -263,8 +285,9 @@ class Init extends Command
$serviceDatabases = ServiceDatabase::all();
foreach ($serviceDatabases as $service) {
if (!data_get($service, 'service')) {
- echo 'ServiceDatabase without service: ' . $service->name . ' deleting\n';
+ echo 'ServiceDatabase without service: ' . $service->name . ' soft deleting\n';
$service->delete();
+ continue;
}
}
} catch (\Throwable $e) {
diff --git a/app/Models/Application.php b/app/Models/Application.php
index d56be8f0a5..e58d4a0281 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Relations\HasMany;
+use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection;
use Spatie\Activitylog\Models\Activity;
use Illuminate\Support\Str;
@@ -13,6 +14,7 @@ use Visus\Cuid2\Cuid2;
class Application extends BaseModel
{
+ use SoftDeletes;
protected $guarded = [];
protected static function booted()
diff --git a/app/Models/ServiceApplication.php b/app/Models/ServiceApplication.php
index b8e3f1a41b..5103952665 100644
--- a/app/Models/ServiceApplication.php
+++ b/app/Models/ServiceApplication.php
@@ -4,11 +4,12 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Cache;
class ServiceApplication extends BaseModel
{
- use HasFactory;
+ use HasFactory, SoftDeletes;
protected $guarded = [];
protected static function booted()
diff --git a/app/Models/ServiceDatabase.php b/app/Models/ServiceDatabase.php
index 79c1dd176f..0bde42c20c 100644
--- a/app/Models/ServiceDatabase.php
+++ b/app/Models/ServiceDatabase.php
@@ -3,10 +3,11 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\SoftDeletes;
class ServiceDatabase extends BaseModel
{
- use HasFactory;
+ use HasFactory, SoftDeletes;
protected $guarded = [];
protected static function booted()
diff --git a/app/Models/StandaloneMariadb.php b/app/Models/StandaloneMariadb.php
index 8893632d3a..33c00260e6 100644
--- a/app/Models/StandaloneMariadb.php
+++ b/app/Models/StandaloneMariadb.php
@@ -6,10 +6,11 @@ use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
+use Illuminate\Database\Eloquent\SoftDeletes;
class StandaloneMariadb extends BaseModel
{
- use HasFactory;
+ use HasFactory,SoftDeletes;
protected $guarded = [];
protected $casts = [
diff --git a/app/Models/StandaloneMongodb.php b/app/Models/StandaloneMongodb.php
index c041c9407d..d08c04adbc 100644
--- a/app/Models/StandaloneMongodb.php
+++ b/app/Models/StandaloneMongodb.php
@@ -5,10 +5,11 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
+use Illuminate\Database\Eloquent\SoftDeletes;
class StandaloneMongodb extends BaseModel
{
- use HasFactory;
+ use HasFactory, SoftDeletes;
protected $guarded = [];
protected static function booted()
diff --git a/app/Models/StandaloneMysql.php b/app/Models/StandaloneMysql.php
index a4691b9b25..02f8f82c4b 100644
--- a/app/Models/StandaloneMysql.php
+++ b/app/Models/StandaloneMysql.php
@@ -5,10 +5,11 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
+use Illuminate\Database\Eloquent\SoftDeletes;
class StandaloneMysql extends BaseModel
{
- use HasFactory;
+ use HasFactory, SoftDeletes;
protected $guarded = [];
protected $casts = [
diff --git a/app/Models/StandalonePostgresql.php b/app/Models/StandalonePostgresql.php
index e0db00d764..df9d284600 100644
--- a/app/Models/StandalonePostgresql.php
+++ b/app/Models/StandalonePostgresql.php
@@ -5,10 +5,11 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
+use Illuminate\Database\Eloquent\SoftDeletes;
class StandalonePostgresql extends BaseModel
{
- use HasFactory;
+ use HasFactory, SoftDeletes;
protected $guarded = [];
protected $casts = [
diff --git a/app/Models/StandaloneRedis.php b/app/Models/StandaloneRedis.php
index 95add8315b..7ccde7f68c 100644
--- a/app/Models/StandaloneRedis.php
+++ b/app/Models/StandaloneRedis.php
@@ -5,10 +5,11 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
+use Illuminate\Database\Eloquent\SoftDeletes;
class StandaloneRedis extends BaseModel
{
- use HasFactory;
+ use HasFactory, SoftDeletes;
protected $guarded = [];
protected static function booted()
diff --git a/database/migrations/2023_12_13_110214_add_soft_deletes.php b/database/migrations/2023_12_13_110214_add_soft_deletes.php
new file mode 100644
index 0000000000..ab7b562b41
--- /dev/null
+++ b/database/migrations/2023_12_13_110214_add_soft_deletes.php
@@ -0,0 +1,71 @@
+<?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::table('applications', function (Blueprint $table) {
+ $table->softDeletes();
+ });
+ Schema::table('standalone_postgresqls', function (Blueprint $table) {
+ $table->softDeletes();
+ });
+ Schema::table('standalone_redis', function (Blueprint $table) {
+ $table->softDeletes();
+ });
+ Schema::table('standalone_mongodbs', function (Blueprint $table) {
+ $table->softDeletes();
+ });
+ Schema::table('standalone_mysqls', function (Blueprint $table) {
+ $table->softDeletes();
+ });
+ Schema::table('standalone_mariadbs', function (Blueprint $table) {
+ $table->softDeletes();
+ });
+ Schema::table('service_applications', function (Blueprint $table) {
+ $table->softDeletes();
+ });
+ Schema::table('service_databases', function (Blueprint $table) {
+ $table->softDeletes();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('applications', function (Blueprint $table) {
+ $table->dropSoftDeletes();
+ });
+ Schema::table('standalone_postgresqls', function (Blueprint $table) {
+ $table->dropSoftDeletes();
+ });
+ Schema::table('standalone_redis', function (Blueprint $table) {
+ $table->dropSoftDeletes();
+ });
+ Schema::table('standalone_mongodbs', function (Blueprint $table) {
+ $table->dropSoftDeletes();
+ });
+ Schema::table('standalone_mysqls', function (Blueprint $table) {
+ $table->dropSoftDeletes();
+ });
+ Schema::table('standalone_mariadbs', function (Blueprint $table) {
+ $table->dropSoftDeletes();
+ });
+ Schema::table('service_applications', function (Blueprint $table) {
+ $table->dropSoftDeletes();
+ });
+ Schema::table('service_databases', function (Blueprint $table) {
+ $table->dropSoftDeletes();
+ });
+
+ }
+};