2020_07_27_194557_create_diary_sleeps_table.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. class CreateDiarySleepsTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('diary_sleeps', function (Blueprint $table) {
  15. $table->id();
  16. $table->bigInteger('uid')->comment('用户id');
  17. $table->bigInteger('level_id')->comment('等级id')->index();
  18. $table->date('day')->comment('某天');
  19. $table->dateTime('start_time')->comment('开始时间');
  20. $table->dateTime('end_time')->comment('结束时间');
  21. $table->string('duration_of_time')->comment('持续时间');
  22. $table->decimal('score', 10, 2)->default(0.00)->comment('睡眠得分');
  23. $table->string('repeat')->comment('去重 day:uid')->unique();
  24. $table->timestamps();
  25. $table->softDeletes();
  26. });
  27. }
  28. /**
  29. * Reverse the migrations.
  30. *
  31. * @return void
  32. */
  33. public function down()
  34. {
  35. Schema::dropIfExists('diary_sleeps');
  36. }
  37. }