Files
Caramel-CRM/database/migrations/2025_11_21_081606_create_notes_table.php
T

37 lines
857 B
PHP

<?php
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(): void
{
Schema::create('notes', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->nullOnDelete();
$table->text('text');
// Polymorphische Beziehung
$table->unsignedBigInteger('notable_id');
$table->string('notable_type');
$table->timestamps();
$table->index(['user_id', 'notable_id', 'notable_type']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('notes');
}
};