<?php
//Migrations acts as a version control for the database allowing you to modify the app's database schema

//allows use of necessary libraries
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateWashingReservations extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('washing_reservations', function (Blueprint $table) {
            $table->id();
            $table->timestamp("time");
            $table->timestamps();

            $table->foreignid("machine_id")->constrained("washing_machines", "id");
            $table->foreignid("user_id")->constrained("users", "id");
            $table->unique(['time', 'machine_id']);
        });
    }

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