Record explicit workshop acceptance and preserve subsequent synthetic work without accepting receivables. Keep 080000/070000 unapplied, real workshop grants pending and operational issuance blocks intact. Exclude local credentials and real-data preservation reports.
19 lines
1.4 KiB
PHP
19 lines
1.4 KiB
PHP
<?php
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
return new class extends Migration {
|
|
public function up(): void
|
|
{
|
|
$old=substr(DB::selectOne("SELECT pg_get_constraintdef(oid) AS d FROM pg_constraint WHERE conrelid='permission_grants'::regclass AND conname='permission_grants_scope_check'")->d,6);
|
|
DB::statement('ALTER TABLE permission_grants DROP CONSTRAINT permission_grants_scope_check');
|
|
DB::statement("ALTER TABLE permission_grants ADD CONSTRAINT permission_grants_scope_check CHECK (($old) OR (permission IN ('service_receivables.view','service_receivables.prepare','service_receivables.confirm','service_receivables.allocate','service_receivables.reconcile','service_receivables.correction_request','service_receivables.correction_approve') AND unit_id IS NOT NULL))");
|
|
DB::unprepared(file_get_contents(__DIR__.'/../sql/receivables.sql'));
|
|
foreach (['sr_records','sr_effects','sr_commands','sr_events','sr_outbox','sr_deliveries'] as $table) {
|
|
DB::statement("CREATE TRIGGER {$table}_immutable BEFORE UPDATE OR DELETE ON {$table} FOR EACH ROW EXECUTE FUNCTION sgf_append_only_audit()");
|
|
DB::statement("CREATE TRIGGER {$table}_test_only BEFORE INSERT ON {$table} FOR EACH ROW EXECUTE FUNCTION sgf_sr_test_insert()");
|
|
}
|
|
}
|
|
public function down(): void { throw new RuntimeException('Immutable history requires a reviewed preservation procedure.'); }
|
|
};
|