feat(editorial): review demographic batches before explicit publication
This commit is contained in:
@@ -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');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user