浏览代码

Add migration

Daniel Supernault 2 年之前
父节点
当前提交
923dfdbaaa
共有 1 个文件被更改,包括 38 次插入0 次删除
  1. 38 0
      database/migrations/2022_10_07_045520_add_reblog_of_id_index_to_statuses_table.php

+ 38 - 0
database/migrations/2022_10_07_045520_add_reblog_of_id_index_to_statuses_table.php

@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddReblogOfIdIndexToStatusesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('statuses', function (Blueprint $table) {
+            $sc = Schema::getConnection()->getDoctrineSchemaManager();
+            if(array_key_exists('statuses_in_reply_or_reblog_index', $sc)) {
+                $table->dropIndex('statuses_in_reply_or_reblog_index');
+            }
+
+            $table->index('in_reply_to_id');
+            $table->index('reblog_of_id');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('statuses', function (Blueprint $table) {
+            //
+        });
+    }
+}