2019_03_22_112409_create_blog_articles_table.php 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. use Illuminate\Database\Schema\Blueprint;
  3. use Illuminate\Database\Migrations\Migration;
  4. class CreateBlogArticlesTable extends Migration
  5. {
  6. public function up()
  7. {
  8. Schema::create('blog_articles', function(Blueprint $table) {
  9. $table->increments('id');
  10. $table->string('title')->index()->comment('帖子标题');
  11. $table->text('body')->comment('帖子内容');
  12. $table->integer('user_id')->unsigned()->index()->comment('用户 ID');
  13. $table->integer('category_id')->unsigned()->index()->comment('分类 ID');
  14. $table->integer('reply_count')->unsigned()->default(0)->comment('回复数量');
  15. $table->integer('view_count')->unsigned()->default(0)->comment('查看总数');
  16. $table->integer('vote_count')->unsigned()->default(0)->comment('喜欢总数-赞');
  17. $table->integer('last_reply_user_id')->unsigned()->default(0)->comment('最后回复的用户 ID');
  18. $table->integer('order')->unsigned()->default(0)->comment('可用来做排序使用');
  19. $table->text('excerpt')->nullable()->comment('文章摘要');
  20. $table->string('slug')->nullable()->comment('SEO7友好的 URI');
  21. $table->timestamps();
  22. });
  23. }
  24. public function down()
  25. {
  26. Schema::drop('blog_articles');
  27. }
  28. }