feat(database): remove 'database_rules' from WebsiteTypeExtra configurations and related tests

This commit is contained in:
2026-07-31 09:28:12 -03:00
parent 6b3a12b624
commit cbb7b1c3a1
5 changed files with 32 additions and 78 deletions

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
public function up(): void
{
DB::table('website_type_extras')
->select(['id', 'config_schema'])
->orderBy('id')
->each(function (object $definition): void {
$schema = json_decode($definition->config_schema, true);
if (! is_array($schema) || ! array_key_exists('database_rules', $schema)) {
return;
}
unset($schema['database_rules']);
DB::table('website_type_extras')
->where('id', $definition->id)
->update(['config_schema' => json_encode($schema)]);
});
}
public function down(): void
{
// Removed rules cannot be reconstructed generically.
}
};

View File

@@ -31,10 +31,6 @@ class WebsiteTypeSeeder extends Seeder
'attachment_type' => 'image',
],
],
'database_rules' => [
'$' => 'required|array',
'$.*' => 'required|integer|distinct|exists:attachments,id',
],
],
],
);
@@ -65,14 +61,6 @@ class WebsiteTypeSeeder extends Seeder
'attachment_type' => 'image',
],
],
'database_rules' => [
'$' => 'required|array',
'title_html' => 'nullable|string',
'description_html' => 'nullable|string',
'button_text' => 'nullable|string',
'button_href' => 'nullable|string',
'background_image_id' => 'nullable|integer|exists:attachments,id',
],
],
],
);
@@ -93,14 +81,6 @@ class WebsiteTypeSeeder extends Seeder
'dates.*' => 'required|date_format:Y-m-d|distinct',
],
'transforms' => [],
'database_rules' => [
'$' => 'required|array',
'title' => 'nullable|string',
'location' => 'nullable|string',
'dates_text' => 'nullable|string|max:255',
'dates' => 'nullable|array',
'dates.*' => 'required|date_format:Y-m-d|distinct',
],
],
],
);