35 lines
849 B
PHP
35 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');
|
||
|
}
|
||
|
};
|