41 lines
1.2 KiB
PHP
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');
|
|
}
|
|
};
|