refactor(form-builder): pre-publish check reads form_field_bindings; drop binding JSON columns
This commit is contained in:
@@ -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');
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user