<?php

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

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

            $table->unsignedInteger('country_id')->index();
            $table->unsignedInteger('product_id')->index();

            $table->decimal('c_price', 8, 2)->nullable();
            $table->decimal('c_tax', 5, 2)->nullable();
            $table->decimal('c_price_old', 8, 2)->nullable();

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

            $table->timestamps();

            $table->foreign('country_id')
                ->references('id')
                ->on('countries');

            $table->foreign('product_id')
                ->references('id')
                ->on('products');
        });
    }

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