47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
class CreateUserActivitiesTable extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function up()
|
|
{
|
|
Schema::create('user_activity', function (Blueprint $table) {
|
|
$table->bigIncrements('id');
|
|
$table->unsignedInteger('user_id');
|
|
$table->dateTime('activity_at');
|
|
$table->string('type', 100);
|
|
$table->unsignedBigInteger('photo_id')->nullable(true);
|
|
$table->unsignedBigInteger('photo_comment_id')->nullable(true);
|
|
$table->timestamps();
|
|
|
|
$table->foreign('user_id')
|
|
->references('id')->on('users')
|
|
->onDelete('cascade');
|
|
$table->foreign('photo_id')
|
|
->references('id')->on('photos')
|
|
->onDelete('cascade');
|
|
$table->foreign('photo_comment_id')
|
|
->references('id')->on('photo_comments')
|
|
->onDelete('cascade');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function down()
|
|
{
|
|
Schema::dropIfExists('user_activity');
|
|
}
|
|
}
|