cineflex/database/migrations/2022_11_22_000012_create_tickets_table.php

37 lines
1.1 KiB
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('tickets', function (Blueprint $table) {
$table->id('ticket_id');
$table->timestamps();
$table->foreignId('order_id')->constrained('orders', 'order_id');
$table->foreignId('showing_id')->constrained('showings', 'showing_id');
$table->foreignId('seat_id')->constrained('seats', 'seat_id');
$table->foreignId('price_id')->constrained('prices', 'price_id');
$table->foreignId('user_id')->constrained('users', 'user_id');
$table->unique(['order_id', 'showing_id', 'seat_id']); // only one ticket per seat per showing per order
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tickets');
}
};