<?php

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

class CreateProductAttrsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('attributes', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('orders')->default(1);;
            $table->timestamps();
        });

        Schema::create('attribute_descriptions', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->string('lang', 10)->index();
            $table->integer('attribute_id')->index();
        });

        Schema::create('product_attributes', function (Blueprint $table) {
            $table->increments('id');
            $table->string('lang', 10)->index();
            $table->integer('product_id')->index();
            $table->integer('attribute_id')->index();
            $table->text('text')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('attributes');
        Schema::drop('attribute_descriptions');
        Schema::drop('product_attributes');
    }
}
