<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Add image optimization configuration to backoffice.
* Allows configuring the maximum dimension (width/height) for uploaded images.
*/
final class Version20251215120000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add image_max_dimension configuration for image upload optimization';
}
public function up(Schema $schema): void
{
// Get the next order_value for System parent
$this->addSql("
SET @order_value = COALESCE((SELECT MAX(`order_value`) FROM `std_config` WHERE `parent_name` = 'System'), 0) + 1
");
$this->addSql("
INSERT IGNORE INTO `std_config` (
`machine_name`,
`created_by`,
`updated_by`,
`value`,
`description_machine_name`,
`details_machine_name`,
`parent_name`,
`variable_type`,
`order_value`,
`is_hidden`,
`is_active`,
`created_date`,
`updated_date`,
`label`,
`content`,
`language_code`
) VALUES (
'image_max_dimension',
1,
1,
'2500',
'image_max_dimension',
'Maximum dimension (width or height in pixels) for uploaded images. Images larger than this will be automatically resized. Set to 0 to disable resizing.',
'System',
'INPUT',
@order_value,
0,
1,
NOW(),
NOW(),
'Image Max Dimension (px)',
NULL,
''
)
");
}
public function down(Schema $schema): void
{
$this->addSql("DELETE FROM `std_config` WHERE `machine_name` = 'image_max_dimension'");
}
}