Explorar o código

Add migrations

Daniel Supernault hai 1 ano
pai
achega
a969ca502f

+ 28 - 0
database/migrations/2024_03_08_122947_add_shared_inbox_attribute_to_instances_table.php

@@ -0,0 +1,28 @@
+<?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('instances', function (Blueprint $table) {
+            $table->string('shared_inbox')->nullable()->index();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::table('instances', function (Blueprint $table) {
+            $table->dropColumn('shared_inbox');
+        });
+    }
+};

+ 32 - 0
database/migrations/2024_03_08_123356_add_shared_inboxes_to_instances_table.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+use App\Instance;
+use App\Profile;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     */
+    public function up(): void
+    {
+        foreach(Instance::lazyById(50, 'id') as $instance) {
+            $si = Profile::whereDomain($instance->domain)->whereNotNull('sharedInbox')->first();
+            if($si && $si->sharedInbox) {
+                $instance->shared_inbox = $si->sharedInbox;
+                $instance->save();
+            }
+        }
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+
+    }
+};