<?php

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

class CreateShopsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::defaultStringLength(191);
        Schema::create('shops', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name')->unique();
            $table->unsignedTinyInteger('plat_id')->comment('平台id');
            $table->string('access_token')->nullable();
            $table->unsignedBigInteger('expires_at')->nullable()->comment('access_token过期时间点');
            $table->unsignedInteger('expires_in')->nullable()->comment('access_token过期时间段，10（表示10秒后过期）');
            $table->string('owner_id')->nullable()->comment('商家店铺id');
            $table->string('owner_name')->nullable()->comment('商家账号名称');
            $table->string('refresh_token')->nullable()->comment('refresh token，可用来刷新access_token');
            $table->unsignedBigInteger('refresh_token_expires_at')->nullable()->comment('Refresh token过期时间点');
            $table->unsignedInteger('refresh_token_expires_in')->nullable()->comment('refresh_token过期时间段，10表示10秒后过期');
            $table->text('scope')->nullable()->comment('接口列表');
            $table->text('pop_auth_token_create_response')->nullable()->comment('授权认证信息');
            $table->unsignedTinyInteger('status')->index()->default(0)->comment('状态');
            $table->softDeletes();
            $table->timestamps();
            //索引
        });
    }

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