2019_03_04_163108_create_room_log_table.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class CreateRoomLogTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('room', function (Blueprint $table) {
  15. $table->engine = 'InnoDB';
  16. $table->collation = 'utf8_unicode_ci';
  17. $table->charset = 'utf8';
  18. $table->bigIncrements('room_id')->comment('房间ID');
  19. $table->string('title')->comment('房间标题');
  20. $table->unsignedTinyInteger('is_full')->default(0)->comment('是否满员 0未满员 1已满员');
  21. $table->unsignedTinyInteger('is_end')->default(0)->comment('是否结束 0未结束 1已结束');
  22. $table->unsignedInteger('user_limit')->default(2)->comment('限定用户数量');
  23. $table->string('nickname')->comment('房主昵称');
  24. $table->unsignedBigInteger('user_id')->comment('房主ID');
  25. $table->dateTime('start_at')->nullable()->useCurrent()->comment('游戏开始时间');
  26. $table->dateTime('created_at')->useCurrent()->comment('创建时间');
  27. $table->dateTime('updated_at')->useCurrent()->comment('更新时间');
  28. $table->dateTime('deleted_at')->nullable()->comment('删除时间');
  29. });
  30. Schema::create('room_user', function (Blueprint $table) {
  31. $table->engine = 'InnoDB';
  32. $table->collation = 'utf8_unicode_ci';
  33. $table->charset = 'utf8';
  34. $table->bigIncrements('ru_id')->comment('房间用户ID');
  35. $table->unsignedBigInteger('room_id')->comment('房间ID');
  36. $table->unsignedBigInteger('user_id')->comment('用户ID');
  37. $table->unsignedInteger('score')->default(0)->comment('获得总分');
  38. $table->unsignedTinyInteger('is_win')->default(0)->comment('是否胜利 0失败 1胜利');
  39. $table->unsignedTinyInteger('state')->default(1)->comment('游戏状态 1正在匹配 2已结束');
  40. $table->dateTime('created_at')->useCurrent()->comment('创建时间');
  41. $table->dateTime('updated_at')->useCurrent()->comment('更新时间');
  42. $table->dateTime('deleted_at')->nullable()->comment('删除时间');
  43. });
  44. Schema::create('user', function (Blueprint $table) {
  45. $table->engine = 'InnoDB';
  46. $table->collation = 'utf8_unicode_ci';
  47. $table->charset = 'utf8';
  48. $table->bigIncrements('user_id')->comment('用户ID');
  49. $table->string('name')->comment('用户名称');
  50. $table->string('avatar')->comment('用户头像');
  51. $table->char('cmcc_id', 32)->comment('移动平台用户ID');
  52. $table->string('mt')->comment('加密令牌');
  53. $table->unsignedInteger('win_count')->default(0)->comment('用户胜利场数');
  54. $table->unsignedInteger('lose_count')->default(0)->comment('用户失败场数');
  55. $table->unsignedTinyInteger('is_login')->default(0)->comment('是否登录 0未登录 1已登录');
  56. $table->unsignedTinyInteger('is_robot')->default(0)->comment('是否机器人 0不是机器人 1机器人');
  57. $table->char('client_id', 20)->nullable()->comment('连接客户端ID');
  58. $table->dateTime('created_at')->useCurrent()->comment('创建时间');
  59. $table->dateTime('updated_at')->useCurrent()->comment('更新时间');
  60. $table->dateTime('deleted_at')->nullable()->comment('删除时间');
  61. });
  62. Schema::create('room_question', function (Blueprint $table) {
  63. $table->engine = 'InnoDB';
  64. $table->collation = 'utf8_unicode_ci';
  65. $table->charset = 'utf8';
  66. $table->bigIncrements('rq_id')->comment('房间问题ID');
  67. $table->unsignedBigInteger('room_id')->comment('房间ID');
  68. $table->unsignedBigInteger('question_id')->comment('问题ID');
  69. $table->string('title')->comment('问题标题');
  70. $table->dateTime('start_at')->useCurrent()->comment('问题开始时间');
  71. $table->dateTime('end_at')->useCurrent()->comment('结算时间');
  72. $table->dateTime('created_at')->useCurrent()->comment('创建时间');
  73. $table->dateTime('updated_at')->useCurrent()->comment('更新时间');
  74. $table->dateTime('deleted_at')->nullable()->comment('删除时间');
  75. });
  76. Schema::create('room_answer', function (Blueprint $table) {
  77. $table->engine = 'InnoDB';
  78. $table->collation = 'utf8_unicode_ci';
  79. $table->charset = 'utf8';
  80. $table->bigIncrements('ra_id')->comment('房间答案ID');
  81. $table->unsignedBigInteger('room_id')->comment('房间ID');
  82. $table->unsignedBigInteger('user_id')->comment('用户ID');
  83. $table->unsignedBigInteger('option_id')->comment('选项ID');
  84. $table->unsignedBigInteger('question_id')->comment('问题ID');
  85. $table->unsignedInteger('score')->comment('分数');
  86. $table->dateTime('created_at')->useCurrent()->comment('创建时间');
  87. $table->dateTime('updated_at')->useCurrent()->comment('更新时间');
  88. $table->dateTime('deleted_at')->nullable()->comment('删除时间');
  89. $table->unique(["room_id", "user_id", "question_id"], 'unique_ruq');
  90. });
  91. }
  92. /**
  93. * Reverse the migrations.
  94. *
  95. * @return void
  96. */
  97. public function down()
  98. {
  99. }
  100. }