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.

Refactor database migrations and update environment variables handling

Andras Bacsai3b12d63f4923
diff --git a/database/migrations/2024_06_25_184323_update_db.php b/database/migrations/2024_06_25_184323_update_db.php
index f1b175a9c6..8f9405b86b 100644
--- a/database/migrations/2024_06_25_184323_update_db.php
+++ b/database/migrations/2024_06_25_184323_update_db.php
@@ -4,6 +4,7 @@ use App\Models\EnvironmentVariable;
use App\Models\Server;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Visus\Cuid2\Cuid2;
@@ -14,44 +15,45 @@ return new class extends Migration
*/
public function up(): void
{
- Schema::table('applications', function (Blueprint $table) {
- $table->dropColumn('docker_compose_pr_location');
- $table->dropColumn('docker_compose_pr');
- $table->dropColumn('docker_compose_pr_raw');
- });
- Schema::table('subscriptions', function (Blueprint $table) {
- $table->dropColumn('lemon_subscription_id');
- $table->dropColumn('lemon_order_id');
- $table->dropColumn('lemon_product_id');
- $table->dropColumn('lemon_variant_id');
- $table->dropColumn('lemon_variant_name');
- $table->dropColumn('lemon_customer_id');
- $table->dropColumn('lemon_status');
- $table->dropColumn('lemon_renews_at');
- $table->dropColumn('lemon_update_payment_menthod_url');
- $table->dropColumn('lemon_trial_ends_at');
- $table->dropColumn('lemon_ends_at');
- });
- Schema::table('environment_variables', function (Blueprint $table) {
- $table->string('uuid')->nullable()->after('id');
- });
+ try {
+ Schema::table('applications', function (Blueprint $table) {
+ $table->dropColumn('docker_compose_pr_location');
+ $table->dropColumn('docker_compose_pr');
+ $table->dropColumn('docker_compose_pr_raw');
+ });
+ Schema::table('subscriptions', function (Blueprint $table) {
+ $table->dropColumn('lemon_subscription_id');
+ $table->dropColumn('lemon_order_id');
+ $table->dropColumn('lemon_product_id');
+ $table->dropColumn('lemon_variant_id');
+ $table->dropColumn('lemon_variant_name');
+ $table->dropColumn('lemon_customer_id');
+ $table->dropColumn('lemon_status');
+ $table->dropColumn('lemon_renews_at');
+ $table->dropColumn('lemon_update_payment_menthod_url');
+ $table->dropColumn('lemon_trial_ends_at');
+ $table->dropColumn('lemon_ends_at');
+ });
+ Schema::table('environment_variables', function (Blueprint $table) {
+ $table->string('uuid')->nullable()->after('id');
+ });
- EnvironmentVariable::all()->each(function (EnvironmentVariable $environmentVariable) {
- $environmentVariable->update([
- 'uuid' => (string) new Cuid2,
- ]);
- });
- Schema::table('environment_variables', function (Blueprint $table) {
- $table->string('uuid')->nullable(false)->change();
- });
- Schema::table('server_settings', function (Blueprint $table) {
- $table->integer('metrics_history_days')->default(7)->change();
- });
- Server::all()->each(function (Server $server) {
- $server->settings->update([
- 'metrics_history_days' => 7,
- ]);
- });
+ EnvironmentVariable::all()->each(function (EnvironmentVariable $environmentVariable) {
+ $environmentVariable->update([
+ 'uuid' => (string) new Cuid2,
+ ]);
+ });
+ Schema::table('environment_variables', function (Blueprint $table) {
+ $table->string('uuid')->nullable(false)->change();
+ });
+ Schema::table('server_settings', function (Blueprint $table) {
+ $table->integer('metrics_history_days')->default(7)->change();
+ });
+
+ DB::table('server_settings')->update(['metrics_history_days' => 7]);
+ } catch (\Exception $e) {
+ loggy($e);
+ }
}
/**