<?php

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

class CreateShippingPricesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('shipping_prices', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('shipping_id');

            $table->decimal('price', 8, 2)->nullable();
            $table->decimal('price_comp', 8, 2)->nullable();
            $table->unsignedTinyInteger('num_comp')->nullable();

            $table->decimal('tax_rate', 5, 2)->nullable();
            $table->decimal('factor', 5, 2)->nullable();

            $table->decimal('total_from', 8, 2)->nullable();
            $table->decimal('total_to', 8, 2)->nullable();

            $table->unsignedInteger('weight_from')->nullable();
            $table->unsignedInteger('weight_to')->nullable();


            $table->timestamps();

            $table->foreign('shipping_id')
                ->references('id')
                ->on('shippings')
                ->onDelete('cascade');
        });
    }

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