feat(form-builder): form_field_validation_rules table + polymorphic owner + scope + cascade
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* WS-5b commit 1 of 5 — relational home for what was `form_fields.validation_rules`
|
||||
* and `form_field_library.validation_rules` JSON. Polymorphic owner (morph
|
||||
* aliases `form_field` and `form_field_library`), one row per
|
||||
* (owner, rule_type) with a typed `rule_type` column and a per-rule
|
||||
* `parameters` JSON bag (ARCH-CONSOLIDATION-ADDENDUM-2026-04-24 §Q3,
|
||||
* ARCH-FORM-BUILDER §17.4).
|
||||
*
|
||||
* This commit is pure infrastructure — no backfill. The legacy JSON bag
|
||||
* is migrated to rows by commit 2's backfill migration so readers and
|
||||
* writers can be switched over as a second atomic step.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('form_field_validation_rules', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->string('owner_type', 40);
|
||||
$table->ulid('owner_id');
|
||||
$table->string('rule_type', 40);
|
||||
$table->json('parameters');
|
||||
$table->string('error_message_key', 100)->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(
|
||||
['owner_type', 'owner_id', 'rule_type'],
|
||||
'ffvr_owner_rule_unique',
|
||||
);
|
||||
$table->index('rule_type', 'ffvr_rule_idx');
|
||||
$table->index(['owner_type', 'owner_id'], 'ffvr_owner_idx');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('form_field_validation_rules');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user