Files
mytodos/database/migrations/2026_10_10_214844_create_invitations_table.php
T
ecdown 177f122c10
tests / ci (push) Canceled after 0s
added roles and organizations
2026-10-15 20:59:32 -07:00

41 lines
1.2 KiB
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('invitations', function (Blueprint $table) {
$table->id();
$table->foreignId('inviter_id')->constrained('users')->cascadeOnDelete();
$table->string('email');
// Workspace invitations store an OrganizationRole; folder
// invitations store a FolderRole. The inviteable type selects
// which role vocabulary applies.
$table->string('role');
$table->morphs('inviteable');
$table->string('token', 64)->unique();
$table->timestamp('expires_at')->nullable();
$table->timestamp('accepted_at')->nullable();
$table->foreignId('accepted_by_id')->nullable()->constrained('users')->nullOnDelete();
$table->timestamps();
$table->unique(['inviteable_type', 'inviteable_id', 'email']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('invitations');
}
};