feat(form-builder): form_field_configs relational table + non-validation key split + drop validation_rules JSON columns

This commit is contained in:
2026-04-24 22:42:35 +02:00
parent 9d2758a42c
commit d494478c08
31 changed files with 1233 additions and 60 deletions

View File

@@ -33,10 +33,11 @@ final class FormFieldBindingMigrationTest extends TestCase
public function test_forward_migrations_backfill_rows_from_both_json_sources(): void
{
// Roll back, newest first: backfill_form_field_validation_rules
// → create_form_field_validation_rules_table (both WS-5b commit 1+2)
// → drop_binding_json_columns → create_form_field_bindings.
$this->artisan('migrate:rollback', ['--step' => 4])->assertSuccessful();
// Roll back to pre-WS-5a state: 5 WS-5b migrations
// (drop-validation-cols, configs-backfill, create-configs,
// validation-rules-backfill, create-validation-rules) +
// 2 WS-5a migrations (drop-binding-cols, create-bindings) = 7.
$this->artisan('migrate:rollback', ['--step' => 7])->assertSuccessful();
$this->assertFalse(Schema::hasTable('form_field_bindings'));
$this->assertTrue(Schema::hasColumn('form_fields', 'binding'));
$this->assertTrue(Schema::hasColumn('form_field_library', 'default_binding'));
@@ -97,23 +98,24 @@ final class FormFieldBindingMigrationTest extends TestCase
public function test_rollback_reconstructs_json_and_drops_table(): void
{
// Walk back the full WS-5b + WS-5a stack: backfill (validation rules)
// → create (validation rules table) → drop (binding columns) →
// create (bindings table).
$this->artisan('migrate:rollback', ['--step' => 4])->assertSuccessful();
// Walk back the full WS-5b + WS-5a stack (7 migrations).
$this->artisan('migrate:rollback', ['--step' => 7])->assertSuccessful();
[$fieldAId, , ] = $this->seedFieldsWithBindingJson();
[$libAId, ] = $this->seedLibraryWithBindingJson();
$this->artisan('migrate')->assertSuccessful();
// Fully-forward state: columns gone, rows in form_field_bindings.
// Fully-forward state: binding columns gone, rows in form_field_bindings.
$this->assertFalse(Schema::hasColumn('form_fields', 'binding'));
$this->assertSame(5, DB::table('form_field_bindings')->count());
// Step back over the two WS-5b migrations → restores the pre-WS-5b
// state (validation-rules table gone; binding contract intact).
$this->artisan('migrate:rollback', ['--step' => 2])->assertSuccessful();
// Step back over all five WS-5b migrations in one go → restores the
// pre-WS-5b state (validation-rules and configs tables gone,
// validation_rules JSON columns reappear on source tables; binding
// contract intact).
$this->artisan('migrate:rollback', ['--step' => 5])->assertSuccessful();
$this->assertFalse(Schema::hasTable('form_field_validation_rules'));
$this->assertFalse(Schema::hasTable('form_field_configs'));
$this->assertTrue(Schema::hasTable('form_field_bindings'));
// Step back over drop_binding_json_columns → columns reappear empty.