commit5
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-30 10:55:18 +02:00
parent 0235c7609e
commit 48347e2d3a
161 changed files with 11814 additions and 265 deletions
@@ -0,0 +1,50 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('supplier_evaluations', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->constrained()->restrictOnDelete();
$table->foreignId('supplier_id')->constrained()->restrictOnDelete();
$table->foreignId('department_id')->nullable()->constrained()->restrictOnDelete();
$table->foreignId('created_by')->constrained('users')->restrictOnDelete();
$table->foreignId('submitted_by')->nullable()->constrained('users')->restrictOnDelete();
$table->foreignId('reviewed_by')->nullable()->constrained('users')->restrictOnDelete();
$table->foreignId('previous_id')->nullable()->unique()->constrained('supplier_evaluations')->restrictOnDelete();
$table->uuid('operation_key');
$table->string('creation_hash', 64);
$table->unsignedInteger('revision')->default(1);
$table->unsignedInteger('version')->default(1);
$table->string('status')->default('draft');
$table->json('contributors');
$table->json('supplier_snapshot');
$table->json('payload');
$table->text('review_reason')->nullable();
$table->timestamp('reviewed_at')->nullable();
$table->timestamps();
$table->unique(['tenant_id', 'operation_key']);
$table->index(['tenant_id', 'supplier_id', 'status']);
});
if (DB::getDriverName() === 'pgsql') {
DB::unprepared("CREATE OR REPLACE FUNCTION sgc_preserve_supplier_evaluation() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN
IF TG_OP = 'DELETE' OR OLD.status = 'approved' THEN RAISE EXCEPTION 'Preservar avaliação aprovada e histórico'; END IF;
RETURN NEW; END $$;
CREATE TRIGGER preserve_supplier_evaluation BEFORE UPDATE OR DELETE ON supplier_evaluations FOR EACH ROW EXECUTE FUNCTION sgc_preserve_supplier_evaluation();");
} elseif (DB::getDriverName() === 'sqlite') {
DB::unprepared("CREATE TRIGGER preserve_supplier_evaluation_delete BEFORE DELETE ON supplier_evaluations BEGIN SELECT RAISE(ABORT, 'Preservar histórico de avaliação'); END;");
DB::unprepared("CREATE TRIGGER preserve_supplier_evaluation_approved BEFORE UPDATE ON supplier_evaluations WHEN OLD.status = 'approved' BEGIN SELECT RAISE(ABORT, 'Preservar avaliação aprovada'); END;");
}
}
public function down(): void
{
throw new LogicException('Preservar avaliações, decisões e histórico.');
}
};
@@ -0,0 +1,50 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('supplier_improvements', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->constrained()->restrictOnDelete();
$table->foreignId('supplier_evaluation_id')->constrained()->restrictOnDelete();
$table->foreignId('created_by')->constrained('users')->restrictOnDelete();
$table->foreignId('responsible_id')->constrained('users')->restrictOnDelete();
$table->uuid('operation_key');
$table->string('creation_hash', 64);
$table->string('title', 200);
$table->text('description');
$table->date('due_on');
$table->unsignedInteger('version')->default(1);
$table->string('status')->default('open');
$table->json('contributors');
$table->text('result')->nullable();
$table->text('evidence')->nullable();
$table->foreignId('reviewed_by')->nullable()->constrained('users')->restrictOnDelete();
$table->text('review_reason')->nullable();
$table->timestamp('reviewed_at')->nullable();
$table->timestamps();
$table->unique(['tenant_id', 'operation_key']);
$table->index(['supplier_evaluation_id', 'status']);
});
if (DB::getDriverName() === 'pgsql') {
DB::unprepared("CREATE FUNCTION sgc_preserve_supplier_improvement() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN
IF TG_OP = 'DELETE' OR OLD.status = 'closed' THEN RAISE EXCEPTION 'Preservar medida encerrada e histórico'; END IF;
RETURN NEW; END $$;
CREATE TRIGGER preserve_supplier_improvement BEFORE UPDATE OR DELETE ON supplier_improvements FOR EACH ROW EXECUTE FUNCTION sgc_preserve_supplier_improvement();");
} elseif (DB::getDriverName() === 'sqlite') {
DB::unprepared("CREATE TRIGGER preserve_supplier_improvement_delete BEFORE DELETE ON supplier_improvements BEGIN SELECT RAISE(ABORT, 'Preservar histórico da medida'); END;");
DB::unprepared("CREATE TRIGGER preserve_supplier_improvement_closed BEFORE UPDATE ON supplier_improvements WHEN OLD.status = 'closed' BEGIN SELECT RAISE(ABORT, 'Preservar medida encerrada'); END;");
}
}
public function down(): void
{
throw new LogicException('Preservar medidas e decisões.');
}
};
@@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('supplier_responses', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->constrained()->restrictOnDelete();
$table->foreignId('supplier_evaluation_id')->constrained()->restrictOnDelete();
$table->foreignId('created_by')->constrained('users')->restrictOnDelete();
$table->uuid('operation_key');
$table->string('creation_hash', 64);
$table->unsignedInteger('version')->default(1);
$table->string('status')->default('draft');
$table->json('payload');
$table->json('contributors');
$table->json('decision')->nullable();
$table->foreignId('reviewed_by')->nullable()->constrained('users')->restrictOnDelete();
$table->text('review_reason')->nullable();
$table->timestamp('reviewed_at')->nullable();
$table->timestamps();
$table->unique(['tenant_id', 'operation_key']);
$table->index(['supplier_evaluation_id', 'status']);
});
if (DB::getDriverName() === 'pgsql') {
DB::unprepared("CREATE FUNCTION sgc_preserve_supplier_response() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN
IF TG_OP = 'DELETE' OR OLD.status = 'decided' THEN RAISE EXCEPTION 'Preservar contraditorio e conclusao'; END IF;
RETURN NEW; END $$;
CREATE TRIGGER preserve_supplier_response BEFORE UPDATE OR DELETE ON supplier_responses FOR EACH ROW EXECUTE FUNCTION sgc_preserve_supplier_response();");
} elseif (DB::getDriverName() === 'sqlite') {
DB::unprepared("CREATE TRIGGER preserve_supplier_response_delete BEFORE DELETE ON supplier_responses BEGIN SELECT RAISE(ABORT, 'Preservar contraditorio'); END;");
DB::unprepared("CREATE TRIGGER preserve_supplier_response_decided BEFORE UPDATE ON supplier_responses WHEN OLD.status = 'decided' BEGIN SELECT RAISE(ABORT, 'Preservar conclusao'); END;");
}
}
public function down(): void
{
throw new LogicException('Preservar contraditórios e conclusões.');
}
};
@@ -0,0 +1,44 @@
<?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('organization_access', function (Blueprint $t) {
$t->id();
$t->foreignId('tenant_id')->unique()->constrained()->restrictOnDelete();
$t->boolean('active')->default(false);
$t->unsignedInteger('version')->default(1);
$t->timestamps();
});
Schema::create('organization_profiles', function (Blueprint $t) {
$t->id();
$t->foreignId('tenant_id')->constrained()->restrictOnDelete();
$t->string('name', 120);
$t->json('permissions');
$t->unsignedInteger('version')->default(1);
$t->timestamps();
$t->unique(['tenant_id', 'name']);
});
Schema::create('organization_memberships', function (Blueprint $t) {
$t->id();
$t->foreignId('tenant_id')->constrained()->restrictOnDelete();
$t->foreignId('user_id')->constrained()->restrictOnDelete();
$t->foreignId('profile_id')->constrained('organization_profiles')->restrictOnDelete();
$t->boolean('maintenance')->default(false);
$t->timestamp('expires_at')->nullable();
$t->text('reason')->nullable();
$t->timestamps();
$t->unique(['tenant_id', 'user_id', 'profile_id']);
});
}
public function down(): void
{
throw new LogicException('Preservar perfis, atribuições e auditoria.');
}
};
+2 -7
View File
@@ -2,7 +2,6 @@
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
@@ -15,11 +14,7 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
// User::factory(10)->create();
User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
]);
// Product installation creates its named administrators through company setup.
// Synthetic accounts belong only to explicitly isolated test/evaluation fixtures.
}
}