<?php

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

class ExpandUserAndPushNotifications extends Migration
{
    const TABLE_USER = 'table_user';
    const TABLE_USER_NOTIFICATION = 'table_user_notification_push';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table(static::TABLE_USER, function (Blueprint $table) {

            $table->string('ios_push_token')->nullable();
        });

        Schema::create(static::TABLE_USER_NOTIFICATION, function (Blueprint $table) {

            $table->uuid('uuid');
            $table->increments('id');

            $table->unsignedInteger('owner_id')->nullable();
            $table->unsignedInteger('user_id')->nullable();
            $table->unsignedInteger('comment_id')->nullable();
            $table->unsignedInteger('capsule_id')->nullable();

            $table->boolean('is_sent')->nullable();
            $table->tinyInteger('type')->nullable();
            $table->string('content')->nullable();
            $table->integer('created_at_micro')->nullable();

            $table->string('hash');

            $table->timestamps();
        });

    }

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