2015_10_09_154125_create_answers_table.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class CreateAnswersTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('answers', function (Blueprint $table) {
  15. $table->increments('id')->unsigned(); //回答ID
  16. $table->string('question_title',255); //问题标题
  17. $table->integer('question_id')->unsigned()->default(0)->index(); //问题ID
  18. $table->integer('user_id')->unsigned()->default(0)->index(); //回答发起人UID
  19. $table->text('content'); //回答内容
  20. $table->integer('supports')->unsigned()->default(0); //支持数
  21. $table->integer('oppositions')->unsigned()->default(0); //反对数
  22. $table->integer('comments')->unsigned()->default(0); //评论数
  23. $table->tinyInteger('device')->default(1)->comment("设备类型:1web版本,2小程序"); //提问设备类型1pc,2安卓,3IOS,4weixin
  24. $table->tinyInteger('status')->default(0); //回答状态0待审核,1已审核
  25. $table->timestamp('adopted_at')->nullable()->index(); //回答采纳时间
  26. $table->timestamps(); //创建和更新时间
  27. $table->index('created_at');
  28. $table->index('updated_at');
  29. });
  30. }
  31. /**
  32. * Reverse the migrations.
  33. *
  34. * @return void
  35. */
  36. public function down()
  37. {
  38. Schema::drop('answers');
  39. }
  40. }