Pārlūkot izejas kodu

评论点赞字段

wzq 5 gadi atpakaļ
vecāks
revīzija
5d072671cd

+ 35 - 0
database/migrations/2019_09_17_164727_add_like_count_to_table_post_comment.php

@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddLikeCountToTablePostComment extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('post_comment', function (Blueprint $table) {
+            $table->integer('like_count')
+                ->default(0)
+                ->after('reply_count')
+                ->comment('点赞数');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('post_comment', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 42 - 0
database/migrations/2019_09_17_164932_create_table_post_comment_like.php

@@ -0,0 +1,42 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateTablePostCommentLike extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('post_comment_like', function (Blueprint $table) {
+            $table->bigIncrements('id');
+
+            $table->integer('uid')
+                ->default(0)
+                ->comment('用户uid');
+
+            $table->integer('comment_id')
+                ->default(0)
+                ->comment('评论id');
+
+            $table->index(['uid', 'comment_id'], 'idx_uid_comment_id');
+
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('post_comment_like');
+    }
+}