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.

feat add uuid to environments

peaklabs-dev3e2e24dcca0e
diff --git a/database/migrations/2024_11_22_124742_add_uuid_to_environments_table.php b/database/migrations/2024_11_22_124742_add_uuid_to_environments_table.php
new file mode 100644
index 0000000000..b106427afe
--- /dev/null
+++ b/database/migrations/2024_11_22_124742_add_uuid_to_environments_table.php
@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Schema;
+use Visus\Cuid2\Cuid2;
+
+return new class extends Migration
+{
+ public function up(): void
+ {
+ Schema::table('environments', function (Blueprint $table) {
+ $table->string('uuid')->after('id')->nullable()->unique();
+ });
+
+ DB::table('environments')
+ ->whereNull('uuid')
+ ->chunkById(100, function ($environments) {
+ foreach ($environments as $environment) {
+ DB::table('environments')
+ ->where('id', $environment->id)
+ ->update(['uuid' => (string) new Cuid2]);
+ }
+ });
+
+ Schema::table('environments', function (Blueprint $table) {
+ $table->string('uuid')->nullable(false)->change();
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::table('environments', function (Blueprint $table) {
+ $table->dropColumn('uuid');
+ });
+ }
+};