Skip to content

Commit

Permalink
feat: Add migration for ratings table with foreign
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] committed Mar 11, 2024
1 parent d06f847 commit fb84d0c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions database/migrations/2023_04_01_000001_create_ratings_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateRatingsTable extends Migration
{
public function up()
{
Schema::create('ratings', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id');
$table->unsignedBigInteger('product_id');
$table->integer('rating');
$table->timestamps();

$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
});
}

public function down()
{
Schema::dropIfExists('ratings');
}
}

0 comments on commit fb84d0c

Please sign in to comment.