|
@@ -0,0 +1,108 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+use Illuminate\Support\Facades\Schema;
|
|
|
+use Illuminate\Database\Schema\Blueprint;
|
|
|
+use Illuminate\Database\Migrations\Migration;
|
|
|
+
|
|
|
+class CreateRoomLogTable extends Migration
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * Run the migrations.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function up()
|
|
|
+ {
|
|
|
+ Schema::create('room', function (Blueprint $table) {
|
|
|
+ $table->engine = 'InnoDB';
|
|
|
+ $table->collation = 'utf8_unicode_ci';
|
|
|
+ $table->charset = 'utf8';
|
|
|
+ $table->bigIncrements('room_id')->comment('房间ID');
|
|
|
+ $table->string('title')->comment('房间标题');
|
|
|
+ $table->unsignedTinyInteger('is_full')->default(0)->comment('是否满员 0未满员 1已满员');
|
|
|
+ $table->unsignedTinyInteger('is_end')->default(0)->comment('是否结束 0未结束 1已结束');
|
|
|
+ $table->unsignedInteger('user_limit')->default(2)->comment('限定用户数量');
|
|
|
+ $table->string('nickname')->comment('房主昵称');
|
|
|
+ $table->unsignedBigInteger('user_id')->comment('房主ID');
|
|
|
+ $table->dateTime('start_at')->useCurrent()->comment('游戏开始时间');
|
|
|
+ $table->dateTime('created_at')->useCurrent()->comment('创建时间');
|
|
|
+ $table->dateTime('updated_at')->useCurrent()->comment('更新时间');
|
|
|
+ $table->dateTime('deleted_at')->comment('删除时间');
|
|
|
+ });
|
|
|
+
|
|
|
+ Schema::create('room_user', function (Blueprint $table) {
|
|
|
+ $table->engine = 'InnoDB';
|
|
|
+ $table->collation = 'utf8_unicode_ci';
|
|
|
+ $table->charset = 'utf8';
|
|
|
+ $table->bigIncrements('ru_id')->comment('房间用户ID');
|
|
|
+ $table->unsignedBigInteger('room_id')->comment('房间ID');
|
|
|
+ $table->unsignedBigInteger('user_id')->comment('用户ID');
|
|
|
+ $table->unsignedInteger('score')->default(0)->comment('获得总分');
|
|
|
+ $table->unsignedTinyInteger('is_win')->default(0)->comment('是否胜利 0失败 1胜利');
|
|
|
+ $table->unsignedTinyInteger('state')->default(1)->comment('游戏状态 1正在匹配 2已结束');
|
|
|
+ $table->dateTime('created_at')->useCurrent()->comment('创建时间');
|
|
|
+ $table->dateTime('updated_at')->useCurrent()->comment('更新时间');
|
|
|
+ $table->dateTime('deleted_at')->comment('删除时间');
|
|
|
+ });
|
|
|
+
|
|
|
+ Schema::create('user', function (Blueprint $table) {
|
|
|
+ $table->engine = 'InnoDB';
|
|
|
+ $table->collation = 'utf8_unicode_ci';
|
|
|
+ $table->charset = 'utf8';
|
|
|
+ $table->bigIncrements('user_id')->comment('用户ID');
|
|
|
+ $table->string('name')->comment('用户名称');
|
|
|
+ $table->string('avatar')->comment('用户头像');
|
|
|
+ $table->char('cmcc_id', 32)->comment('移动平台用户ID');
|
|
|
+ $table->string('mt')->comment('加密令牌');
|
|
|
+ $table->unsignedInteger('win_count')->default(0)->comment('用户胜利场数');
|
|
|
+ $table->unsignedInteger('lose_count')->default(0)->comment('用户失败场数');
|
|
|
+ $table->unsignedTinyInteger('is_login')->default(0)->comment('是否登录 0未登录 1已登录');
|
|
|
+ $table->unsignedTinyInteger('is_robot')->default(0)->comment('是否机器人 0不是机器人 1机器人');
|
|
|
+ $table->char('client_id', 20)->nullable()->comment('连接客户端ID');
|
|
|
+ $table->dateTime('created_at')->useCurrent()->comment('创建时间');
|
|
|
+ $table->dateTime('updated_at')->useCurrent()->comment('更新时间');
|
|
|
+ $table->dateTime('deleted_at')->comment('删除时间');
|
|
|
+ });
|
|
|
+
|
|
|
+ Schema::create('room_question', function (Blueprint $table) {
|
|
|
+ $table->engine = 'InnoDB';
|
|
|
+ $table->collation = 'utf8_unicode_ci';
|
|
|
+ $table->charset = 'utf8';
|
|
|
+ $table->bigIncrements('rq_id')->comment('房间问题ID');
|
|
|
+ $table->unsignedBigInteger('room_id')->comment('房间ID');
|
|
|
+ $table->unsignedBigInteger('question_id')->comment('问题ID');
|
|
|
+ $table->string('title')->comment('问题标题');
|
|
|
+ $table->dateTime('start_at')->useCurrent()->comment('问题开始时间');
|
|
|
+ $table->dateTime('end_at')->useCurrent()->comment('结算时间');
|
|
|
+ $table->dateTime('created_at')->useCurrent()->comment('创建时间');
|
|
|
+ $table->dateTime('updated_at')->useCurrent()->comment('更新时间');
|
|
|
+ $table->dateTime('deleted_at')->comment('删除时间');
|
|
|
+ });
|
|
|
+
|
|
|
+ Schema::create('room_answer', function (Blueprint $table) {
|
|
|
+ $table->engine = 'InnoDB';
|
|
|
+ $table->collation = 'utf8_unicode_ci';
|
|
|
+ $table->charset = 'utf8';
|
|
|
+ $table->bigIncrements('ra_id')->comment('房间答案ID');
|
|
|
+ $table->unsignedBigInteger('room_id')->comment('房间ID');
|
|
|
+ $table->unsignedBigInteger('user_id')->comment('用户ID');
|
|
|
+ $table->unsignedBigInteger('option_id')->comment('选项ID');
|
|
|
+ $table->unsignedBigInteger('question_id')->comment('问题ID');
|
|
|
+ $table->unsignedInteger('score')->comment('分数');
|
|
|
+ $table->dateTime('created_at')->useCurrent()->comment('创建时间');
|
|
|
+ $table->dateTime('updated_at')->useCurrent()->comment('更新时间');
|
|
|
+ $table->dateTime('deleted_at')->comment('删除时间');
|
|
|
+ $table->unique(["room_id", "user_id", "question_id"], 'unique_ruq');
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Reverse the migrations.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function down()
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+}
|