cineflex/database/migrations/2022_11_22_000007_create_ratings_table.php

36 lines
841 B
PHP
Raw Normal View History

2022-11-23 09:32:34 +01:00
<?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('ratings', function (Blueprint $table) {
$table->id('rating_id');
$table->timestamps();
$table->decimal('rating_value', 3, 1);
$table->foreignId('movie_id')->constrained('movies', 'movie_id');
$table->foreignId('user_id')->constrained('users', 'user_id');
$table->unique(['movie_id', 'user_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('ratings');
}
};