|
| 1 | +<?php |
| 2 | + |
| 3 | +use Illuminate\Support\Facades\Schema; |
| 4 | +use Illuminate\Database\Schema\Blueprint; |
| 5 | +use Illuminate\Database\Migrations\Migration; |
| 6 | + |
| 7 | +class CreateCommentsTable extends Migration |
| 8 | +{ |
| 9 | + /** |
| 10 | + * Run the migrations. |
| 11 | + * |
| 12 | + * @return void |
| 13 | + */ |
| 14 | + public function up() |
| 15 | + { |
| 16 | + Schema::create('comments', function (Blueprint $table) { |
| 17 | + $table->increments('id'); |
| 18 | + $table->string('content', 255)->default('')->comment('content'); |
| 19 | + $table->string('uuid')->unique(); |
| 20 | + $table->string('title', 255)->default('')->comment('title'); |
| 21 | + $table->string('keywords')->default('')->comment('keywords'); |
| 22 | + $table->longText('markdown')->nullable()->comment('markdown content'); |
| 23 | + $table->integer('user_id')->default(0)->comment('author id'); |
| 24 | + $table->integer('cate_id')->default(0)->comment('category id'); |
| 25 | + $table->integer('comment_count')->default(0)->comment('comment count'); |
| 26 | + $table->integer('read_count')->default(0)->comment('read count'); |
| 27 | + $table->tinyInteger('status')->default(1)->comment('status: 1-public;0-private'); |
| 28 | + $table->integer('sort')->default(0)->comment('sort'); |
| 29 | + $table->tinyInteger('is_top')->default(0)->comment('sticky to top'); |
| 30 | + $table->integer('updated_at'); |
| 31 | + $table->integer('created_at'); |
| 32 | + $table->integer('deleted_at')->nullable(); |
| 33 | + $table->index('title'); |
| 34 | + $table->index('cate_id'); |
| 35 | + $table->index('user_id'); |
| 36 | + $table->index('created_at'); |
| 37 | + }); |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * Reverse the migrations. |
| 42 | + * |
| 43 | + * @return void |
| 44 | + */ |
| 45 | + public function down() |
| 46 | + { |
| 47 | + Schema::dropIfExists('comments'); |
| 48 | + } |
| 49 | +} |
0 commit comments