Files
monica/database/migrations/2021_10_21_013005_create_notes_table.php

44 lines
1.2 KiB
PHP

<?php
use App\Helpers\ScoutHelper;
use App\Models\Contact;
use App\Models\Emotion;
use App\Models\User;
use App\Models\Vault;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up()
{
Schema::create('notes', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(Contact::class)->constrained()->cascadeOnDelete();
$table->foreignIdFor(Vault::class)->constrained()->cascadeOnDelete();
$table->foreignIdFor(User::class, 'author_id')->nullable()->constrained('users')->nullOnDelete();
$table->foreignIdFor(Emotion::class)->nullable()->constrained()->nullOnDelete();
$table->string('title')->nullable();
$table->text('body');
$table->timestamps();
if (ScoutHelper::isFullTextIndex()) {
$table->fullText('title');
$table->fullText('body');
}
});
}
/**
* Reverse the migrations.
*/
public function down()
{
Schema::dropIfExists('notes');
}
};