<?php

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

class CreateShopShipsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable('shop_ships')) {
            return;
        }
        Schema::create('shop_ships', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('shop_id');
            $table->string('access_token');
            $table->unsignedBigInteger('expires_at')->comment('access_token过期时间点');
            $table->unsignedInteger('expires_in')->comment('access_token过期时间段，10（表示10秒后过期）');
            $table->string('owner_id')->comment('商家店铺id');
            $table->string('owner_name')->comment('商家账号名称');
            $table->string('refresh_token')->comment('refresh token，可用来刷新access_token');
            $table->unsignedBigInteger('refresh_token_expires_at')->comment('Refresh token过期时间点');
            $table->unsignedInteger('refresh_token_expires_in')->comment('refresh_token过期时间段，10表示10秒后过期');
            $table->text('scope')->comment('接口列表');
            $table->tinyInteger('status')->default(0);
            $table->timestamps();
        });
    }

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