feat(editorial): review demographic batches before explicit publication

This commit is contained in:
2026-11-14 08:35:11 +02:00
parent 2459d0ca37
commit 3c4c2599f7
17 changed files with 825 additions and 62 deletions
@@ -0,0 +1,35 @@
<?php
use App\Support\IsolatedQaDatabase;
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
{
if (! IsolatedQaDatabase::allowsSchemaChanges()) {
throw new RuntimeException('Only isolated QA is authorised.');
}
Schema::table('portal_editorial_editions', function (Blueprint $table): void {
$table->foreignUuid('demographic_import_id')->nullable()->constrained('demographic_imports')->restrictOnDelete();
$table->unique(['demographic_import_id', 'revision_no'], 'editorial_demographic_revision_unique');
});
DB::statement('ALTER TABLE portal_editorial_editions DROP CONSTRAINT portal_editorial_edition_subject, ADD CONSTRAINT portal_editorial_edition_subject CHECK (num_nonnulls(resource_id,dossier_id,demographic_import_id)=1)');
}
public function down(): void
{
if (! IsolatedQaDatabase::allowsSchemaChanges() || DB::table('portal_editorial_editions')->whereNotNull('demographic_import_id')->exists()) {
throw new RuntimeException('Preserve demographic editorial history.');
}
DB::statement('ALTER TABLE portal_editorial_editions DROP CONSTRAINT portal_editorial_edition_subject, ADD CONSTRAINT portal_editorial_edition_subject CHECK (num_nonnulls(resource_id,dossier_id)=1)');
Schema::table('portal_editorial_editions', function (Blueprint $table): void {
$table->dropUnique('editorial_demographic_revision_unique');
$table->dropForeign(['demographic_import_id']);
$table->dropColumn('demographic_import_id');
});
}
};