36 lines
957 B
PHP
36 lines
957 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('messages', function (Blueprint $table) {
|
||
|
|
$table->id();
|
||
|
|
$table->foreignId('folder_id')->constrained()->cascadeOnDelete();
|
||
|
|
$table->string('type'); // invite, situation, file_request, confirmation, text
|
||
|
|
$table->text('body');
|
||
|
|
$table->string('sent_by_type'); // user, client
|
||
|
|
$table->unsignedBigInteger('sent_by_id');
|
||
|
|
$table->json('metadata')->nullable();
|
||
|
|
$table->timestamps();
|
||
|
|
|
||
|
|
$table->index(['folder_id', 'created_at']);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Reverse the migrations.
|
||
|
|
*/
|
||
|
|
public function down(): void
|
||
|
|
{
|
||
|
|
Schema::dropIfExists('messages');
|
||
|
|
}
|
||
|
|
};
|