2019_03_03_180350_create_question_table.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class CreateQuestionTable 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->engine = 'InnoDB';
  16. $table->collation = 'utf8_unicode_ci';
  17. $table->charset = 'utf8';
  18. $table->bigIncrements('question_id')->comment('问题ID');
  19. $table->string('title')->comment('问题标题');
  20. $table->unsignedTinyInteger('is_released')->comment('是否发布');
  21. $table->dateTime('created_at')->useCurrent()->comment('创建时间');
  22. $table->dateTime('updated_at')->useCurrent()->comment('更新时间');
  23. $table->dateTime('deleted_at')->comment('删除时间');
  24. });
  25. Schema::create('options', function (Blueprint $table) {
  26. $table->engine = 'InnoDB';
  27. $table->collation = 'utf8_unicode_ci';
  28. $table->charset = 'utf8';
  29. $table->bigIncrements('option_id')->comment('选项ID');
  30. $table->string('title')->comment('选项标题');
  31. $table->unsignedBigInteger('question_id')->unsigned()->comment('问题ID');
  32. $table->unsignedTinyInteger('is_answer')->comment('是否答案');
  33. $table->dateTime('created_at')->useCurrent()->comment('创建时间');
  34. $table->dateTime('updated_at')->useCurrent()->comment('更新时间');
  35. $table->dateTime('deleted_at')->comment('删除时间');
  36. });
  37. }
  38. /**
  39. * Reverse the migrations.
  40. *
  41. * @return void
  42. */
  43. public function down()
  44. {
  45. Schema::dropIfExists('question');
  46. }
  47. }