53 lines
1.6 KiB
PHP
53 lines
1.6 KiB
PHP
<?php
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
class CreatePhotoCommentsTable extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function up()
|
|
{
|
|
Schema::create('photo_comments', function (Blueprint $table) {
|
|
$table->bigIncrements('id');
|
|
$table->unsignedBigInteger('photo_id');
|
|
$table->string('name');
|
|
$table->string('email');
|
|
$table->text('comment');
|
|
$table->unsignedInteger('created_user_id')->nullable(true);
|
|
$table->unsignedInteger('approved_user_id')->nullable(true);
|
|
$table->dateTime('approved_at')->nullable(true);
|
|
$table->unsignedBigInteger('parent_comment_id')->nullable(true);
|
|
$table->timestamps();
|
|
|
|
$table->foreign('photo_id')
|
|
->references('id')->on('photos')
|
|
->onDelete('cascade');
|
|
$table->foreign('created_user_id')
|
|
->references('id')->on('users')
|
|
->onDelete('cascade');
|
|
$table->foreign('approved_user_id')
|
|
->references('id')->on('users')
|
|
->onDelete('cascade');
|
|
$table->foreign('parent_comment_id')
|
|
->references('id')->on('photo_comments')
|
|
->onDelete('cascade');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function down()
|
|
{
|
|
Schema::dropIfExists('photo_comments');
|
|
}
|
|
}
|