cineflex/database/migrations/2022_11_22_000013_create_user_assignment.php
2023-02-02 08:17:38 +01:00

34 lines
849 B
PHP

<?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('user_assignments', function (Blueprint $table) {
$table->id('user_assignment_id');
$table->timestamps();
$table->foreignId('cinema_id')->constrained('cinemas', 'cinema_id');
$table->foreignId('user_id')->constrained('users', 'user_id');
$table->unique(['cinema_id', 'user_id']); // only one user per cinema
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('user_assignments');
}
};