<?php

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

return new class extends Migration
{
	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('photos', function(Blueprint $table)
		{
			$table->id();
			$table->timestamps();
			$table->softDeletes();

			$table->smallInteger('subsectime')->nullable();
			$table->string('filename',256)->index();
			$table->string('file_signature')->index()->nullable();
			$table->dateTimeTz('created')->nullable();
			$table->dateTimeTz('created_manual')->nullable();
			$table->string('signature',64)->index()->nullable();
			$table->integer('height')->nullable();
			$table->integer('width')->nullable();
			$table->integer('orientation')->nullable();
			$table->float('gps_lat',10)->nullable();
			$table->float('gps_lon',10)->nullable();
			$table->binary('thumbnail')->nullable();
			$table->string('identifier')->nullable();

			$table->boolean('duplicate')->default(FALSE)->nullable();
			$table->boolean('flag')->default(FALSE)->nullable();
			$table->boolean('scanned')->default(FALSE)->nullable();
			$table->boolean('ignore_duplicate')->default(FALSE)->nullable();
			$table->boolean('remove')->default(FALSE)->nullable();

			$table->bigInteger('model_id')->unsigned()->nullable();
			$table->foreign('model_id')->references('id')->on('models');

			$table->bigInteger('software_id')->unsigned()->nullable();
			$table->foreign('software_id')->references('id')->on('software');
		});
	}

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