瀏覽代碼

Add migration

Daniel Supernault 1 年之前
父節點
當前提交
7deaaed4dd
共有 1 個文件被更改,包括 34 次插入0 次删除
  1. 34 0
      database/migrations/2023_11_13_062429_add_followers_count_index_to_profiles_table.php

+ 34 - 0
database/migrations/2023_11_13_062429_add_followers_count_index_to_profiles_table.php

@@ -0,0 +1,34 @@
+<?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('profiles', function (Blueprint $table) {
+           $table->index('followers_count', 'profiles_followers_count_index');
+           $table->index('following_count', 'profiles_following_count_index');
+           $table->index('status_count', 'profiles_status_count_index');
+           $table->index('is_private', 'profiles_is_private_index');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::table('profiles', function (Blueprint $table) {
+            $table->dropIndex('profiles_followers_count_index');
+            $table->dropIndex('profiles_following_count_index');
+            $table->dropIndex('profiles_status_count_index');
+            $table->dropIndex('profiles_is_private_index');
+        });
+    }
+};