<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateGroupsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::defaultStringLength(191);
        Schema::create('groups', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedInteger('shop_id')->default(0);
            $table->unsignedInteger('parent_id')->default(0);
            $table->unsignedBigInteger('end_time');
            $table->unsignedTinyInteger('is_save_preview')->comment('是否保存为预览团0-不为预览团,1-预览团');
            $table->unsignedBigInteger('start_time');
            $table->text('title');
            $table->string('activity_no')->nullable()->comment('团号');
            $table->unsignedTinyInteger('create_status')->default(3)->comment('1-创建成功,2-创建失败,3-创建中');
            $table->string('error_msg')->nullable()->comment('create_status为2时有，创建团失败原因');
            $table->text('qr_code_url')->nullable()->comment('create_status为1时有，团小程序二维码图片地址');
            $table->unsignedBigInteger('create_time')->nullable();
            $table->unsignedTinyInteger('is_help_sell')->nullable()->comment('是否帮卖0-我发布的,1-我帮卖的');
            $table->tinyInteger('status')->default(-10)->comment('团状态（-10:待发布/预览中，-5:未开始，1:跟团中，20:已结束，30:已删除');
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('groups');
    }
}
