<?php

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

class CreateAssetsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('assets', function (Blueprint $table) {
            $table->id();
            $table->char('uuid', 36)->index()->unique();
            $table->bigInteger('user_id')->unsigned()->index()->nullable();
            $table->string('name')->index()->nullable();
            $table->string('type', 45)->index()->nullable();
            $table->string('path', 100)->nullable();
            $table->string('mime')->nullable();
            $table->string('filename')->index()->nullable();
            $table->string('extension', 10)->index()->nullable();
            $table->decimal('latitude', 8, 6)->nullable();
            $table->decimal('longitude', 9, 6)->nullable();
            $table->float('accuracy')->nullable();
            $table->timestamps();
            $table->softDeletes();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
        });
    }

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