2015_09_09_033353_create_questions_table.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class CreateQuestionsTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('questions', function (Blueprint $table) {
  15. $table->increments('id')->unsigned(); //问题ID
  16. $table->integer('user_id')->unsigned()->default(0)->index(); //问题发起人UID
  17. $table->string('title',255)->index(); //问题标题
  18. $table->text('description')->nullable(); //问题详情
  19. $table->smallInteger('price')->default(0); //问题价格
  20. $table->tinyInteger('hide')->default(0); //匿名提问
  21. $table->integer('answers')->unsigned()->default(0); //回答数
  22. $table->integer('views')->unsigned()->default(0); //查看数
  23. $table->integer('followers')->unsigned()->default(0); //关注数
  24. $table->integer('collections')->unsigned()->default(0); //收藏数
  25. $table->integer('comments')->unsigned()->default(0); //评论数
  26. $table->tinyInteger('device')->default(1)->comment("设备类型:1web版本,2小程序"); //提问设备类型1pc,2安卓,3IOS,4weixin
  27. $table->tinyInteger('status')->default(0); //提问状态0待审核,1已审核
  28. $table->timestamps(); //创建和更新时间
  29. $table->index('created_at');
  30. $table->index('updated_at');
  31. });
  32. }
  33. /**
  34. * Reverse the migrations.
  35. *
  36. * @return void
  37. */
  38. public function down()
  39. {
  40. Schema::drop('questions');
  41. }
  42. }