<?php

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

class CreateProductsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('products', function (Blueprint $table) {
            $table->increments('id');
            $table->string('slug')->nullable();
            $table->integer('pid')->nullable();
            $table->integer('manufacturer_id')->default(0);
            $table->tinyInteger('recom')->default(0);
            $table->tinyInteger('headline')->default(0);
            $table->tinyInteger('top')->default(0);
            $table->string('number')->nullable();
            $table->decimal('price', 18, 2)->default(0.00);
            $table->integer('hits');
            $table->integer('orders');
            $table->string('linkurl')->nullable();
            $table->boolean('flag')->default(1);
            $table->integer('stock')->default(0);
            $table->text('page_ids')->nullable();
            $table->integer('is_collect')->default(0)->comment('是否采集');
            $table->timestamps();
        });

        Schema::create('product_descriptions', function (Blueprint $table) {
            $table->increments('id');
            $table->char('lang', 10)->index();
            $table->integer('product_id');
            $table->string('title');
            $table->text('imgs')->nullable();
            $table->text('summary')->nullable();
            $table->longText('content')->nullable();
            $table->string('seo_title')->nullable();
            $table->string('seo_keywords')->nullable();
            $table->text('seo_description')->nullable();
            $table->string('og_title')->nullable();
            $table->text('og_description')->nullable();
            $table->string('og_img')->nullable();
            $table->longText('encyclopedia')->nullable();

            $table->index(['lang', 'product_id']);
        });

    }

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