Files
monica/database/migrations/2021_10_21_013005_create_notes_table.php
T
2021-12-04 18:26:14 -05:00

35 lines
957 B
PHP

<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateNotesTable extends Migration
{
/**
* Run the migrations.
*/
public function up()
{
Schema::create('notes', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('contact_id');
$table->unsignedBigInteger('author_id')->nullable();
$table->string('author_name');
$table->string('title')->nullable();
$table->text('body');
$table->timestamps();
$table->foreign('contact_id')->references('id')->on('contacts')->onDelete('cascade');
$table->foreign('author_id')->references('id')->on('users')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down()
{
Schema::dropIfExists('notes');
}
}