refactor(form-builder): pre-publish check reads form_field_bindings; drop binding JSON columns

This commit is contained in:
2026-04-24 20:09:27 +02:00
parent 6933e6d700
commit 61719bf8bf
18 changed files with 375 additions and 97 deletions

View File

@@ -53,7 +53,6 @@ final class FormFieldFactory extends Factory
'is_unique' => false,
'is_pii' => false,
'display_width' => FormFieldDisplayWidth::FULL,
'binding' => null,
'conditional_logic' => null,
'role_restrictions' => null,
'translations' => null,

View File

@@ -36,7 +36,6 @@ final class FormFieldLibraryFactory extends Factory
'validation_rules' => null,
'default_is_required' => false,
'default_is_filterable' => false,
'default_binding' => null,
'translations' => null,
'description' => fake('nl_NL')->sentence(),
'is_active' => true,

View File

@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* WS-5a commit 3 of 4 drops the legacy `form_fields.binding` and
* `form_field_library.default_binding` JSON columns now that every reader
* (pre-publish check, snapshot writer, API resources, mirror writer, field
* CRUD path, and library CRUD path) has been switched to the relational
* `form_field_bindings` table.
*
* Rollback re-adds both columns as nullable JSON but does NOT attempt to
* backfill. The full rollback path for WS-5a as a whole is to first roll
* back the table-creation migration (`2026_04_25_100000_create_form_field_bindings_table`),
* which genuinely reconstructs the JSON. Rolling back *only* this
* column-drop migration leaves the JSON columns empty on purpose
* callers that need the old JSON state must roll back both steps.
*/
return new class extends Migration
{
public function up(): void
{
if (Schema::hasColumn('form_fields', 'binding')) {
Schema::table('form_fields', function (Blueprint $table): void {
$table->dropColumn('binding');
});
}
if (Schema::hasColumn('form_field_library', 'default_binding')) {
Schema::table('form_field_library', function (Blueprint $table): void {
$table->dropColumn('default_binding');
});
}
}
public function down(): void
{
if (! Schema::hasColumn('form_fields', 'binding')) {
Schema::table('form_fields', function (Blueprint $table): void {
$table->json('binding')->nullable()->after('display_width');
});
}
if (! Schema::hasColumn('form_field_library', 'default_binding')) {
Schema::table('form_field_library', function (Blueprint $table): void {
$table->json('default_binding')->nullable()->after('default_is_filterable');
});
}
}
};

View File

@@ -99,7 +99,7 @@ final class FormBuilderDevSeeder
'is_required' => $field['is_required'] ?? false,
'is_filterable' => $field['is_filterable'] ?? false,
'is_pii' => $field['is_pii'] ?? false,
'binding' => null,
'binding' => null, // Pattern B — snapshot embeds null for form-owned fields.
'conditional_logic' => null,
'translations' => null,
'value_storage_hint' => $field['type']->recommendedValueStorageHint()->value,
@@ -372,7 +372,6 @@ final class FormBuilderDevSeeder
'is_admin_only' => false,
'is_pii' => false,
'display_width' => $def['display_width'] ?? 'full',
'binding' => null,
'role_restrictions' => null,
'value_storage_hint' => $def['value_storage_hint'] ?? FormValueStorageHint::JSON,
'sort_order' => $sortOrder + 1,