<?php

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

class CreateTodayPricesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable('today_prices')) {
            return;
        }
        Schema::defaultStringLength(191);
        Schema::create('today_prices', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->date('day');
            $table->string('external_sku_id');
            $table->float('price');
            $table->text('shop_price');
            $table->index(['external_sku_id', 'day']);
            $table->timestamps();
        });
    }

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