move into sonardesk

This commit is contained in:
Mark Gregory
2026-10-12 14:50:13 +01:00
parent 5f0d2ceb72
commit 38b4a7406f
879 changed files with 24021 additions and 1 deletions
@@ -0,0 +1,81 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('workflow_definitions', function (Blueprint $t) {
$t->id();
$t->string('name');
$t->string('slug')->unique();
$t->text('description')->nullable();
$t->string('subject_type')->nullable()->index();
$t->boolean('is_active')->default(true);
$t->timestamps();
});
Schema::create('workflow_stages', function (Blueprint $t) {
$t->id();
$t->foreignId('workflow_definition_id')->constrained()->cascadeOnDelete();
$t->string('name');
$t->string('slug');
$t->unsignedInteger('position')->default(0);
$t->string('required_permission')->nullable();
$t->boolean('is_initial')->default(false);
$t->boolean('is_terminal')->default(false);
$t->boolean('allows_rejection')->default(true);
$t->unsignedInteger('due_days')->nullable();
$t->timestamps();
$t->unique(['workflow_definition_id', 'slug']);
});
Schema::create('workflow_transitions', function (Blueprint $t) {
$t->id();
$t->foreignId('workflow_definition_id')->constrained()->cascadeOnDelete();
$t->foreignId('from_stage_id')->constrained('workflow_stages')->cascadeOnDelete();
$t->foreignId('to_stage_id')->constrained('workflow_stages')->cascadeOnDelete();
$t->string('name');
$t->string('action');
$t->string('required_permission')->nullable();
$t->boolean('requires_comment')->default(false);
$t->timestamps();
});
Schema::create('workflow_instances', function (Blueprint $t) {
$t->id();
$t->foreignId('workflow_definition_id')->constrained()->cascadeOnDelete();
$t->foreignId('workflow_stage_id')->constrained('workflow_stages');
$t->string('subject_type');
$t->unsignedBigInteger('subject_id');
$t->string('status')->default('active');
$t->foreignId('started_by')->nullable()->constrained('users')->nullOnDelete();
$t->foreignId('assigned_to')->nullable()->constrained('users')->nullOnDelete();
$t->timestamp('due_at')->nullable();
$t->timestamp('completed_at')->nullable();
$t->timestamps();
$t->unique(['subject_type', 'subject_id']);
$t->index(['status', 'workflow_stage_id']);
});
Schema::create('workflow_history', function (Blueprint $t) {
$t->id();
$t->foreignId('workflow_instance_id')->constrained()->cascadeOnDelete();
$t->foreignId('from_stage_id')->nullable()->constrained('workflow_stages')->nullOnDelete();
$t->foreignId('to_stage_id')->nullable()->constrained('workflow_stages')->nullOnDelete();
$t->foreignId('user_id')->nullable()->constrained('users')->nullOnDelete();
$t->string('action');
$t->text('comment')->nullable();
$t->json('metadata')->nullable();
$t->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('workflow_history');
Schema::dropIfExists('workflow_instances');
Schema::dropIfExists('workflow_transitions');
Schema::dropIfExists('workflow_stages');
Schema::dropIfExists('workflow_definitions');
}
};