<?php

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

class CreateCompaniesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('companies', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string("name", 200);
            $table->string("slogan", 300)->nullable();
            $table->string("logo_url", 500)->nullable();
            $table->string("cif", 15)->unique();
            $table->string("address", 200);
            $table->string("city", 100);
            $table->string("zipcode");
            $table->string("country", 300);
            $table->string("county", 200);
            $table->string("phone", 50);
            $table->string("email")->unique();
            $table->string("fact_name");
            $table->string("fact_address_line1");
            $table->string("fact_address_line2")->nullable();
            $table->string("fact_zipcode");
            $table->string("fact_city");
            $table->string("fact_county");
            $table->string("fact_country_code", 2); //ISO CODE!!!!
            $table->string("fact_prefix")->nullable();
            $table->string("fact_serie")->default(Carbon::now()->format("Y"));
            $table->string('stripe_id')->nullable()->index();
            $table->string('stripe_payment_method_id')->nullable()->unique();
            $table->string('card_brand')->nullable();
            $table->string('card_last_four', 4)->nullable();
            $table->timestamp('trial_ends_at')->nullable();
            $table->string('stripe_public_key')->nullable();
            $table->string('stripe_private_key')->nullable();

            $table->timestamps();
        });
    }

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