feat(database): remove 'database_rules' from WebsiteTypeExtra configurations and related tests
This commit is contained in:
@@ -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.
|
||||
}
|
||||
};
|
||||
@@ -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',
|
||||
],
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user