<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20220118121232 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
$this->addSql("
INSERT INTO `std_blocks` (`created_by`, `updated_by`, `machine_name`, `is_active`, `created_date`, `updated_date`, `name`, `settings`)
VALUES (1, 1, 'B31_notificationsbar', 1, now(), now(), 'Notifications Bar', '{\"webpackEntries\": [\"B31_notificationsbar\", \"slick-carousel\"]}');
");
//Settings
$this->addSql("
SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='B31_notificationsbar');
INSERT INTO `std_blocks_settings` (`machine_name`, `block_id`, `created_by`, `updated_by`, `name`, `setting_type`, `is_active`, `created_date`, `updated_date`, `order_value`, `settings`) VALUES
('disabled_block', @block_id, 1, 1, 'Disabled block', 'CHECKBOX', 1, now(), now(), -1, NULL),
('separator_styles', @block_id, '1', '1', 'Styles', 'SEPARATOR', '1', now(), now(), '1', NULL),
('extra_block_id', @block_id, '1', '1', 'Block ID', 'INPUT', '1', now(), now(), '2', NULL),
('extra_class', @block_id, '1', '1', 'Extra Class', 'INPUT', '1', now(), now(), '3', NULL),
('separator_spacings', @block_id, '1', '1', 'Spacings', 'SEPARATOR', '1', now(), now(), '4', NULL),
('margin', @block_id, '1', '1', 'Margin [0px 0px 0px 0px]', 'INPUT', '1', now(), now(), '5', NULL),
('padding', @block_id, '1', '1', 'Padding [0px 0px 0px 0px]', 'INPUT', '1', now(), now(), '6', NULL),
('container', @block_id, '1', '1', 'Inside Container', 'CHECKBOX', '1', now(), now(), '7', NULL),
('bgcolor', @block_id, '1', '1', 'Background color', 'COLORPICKER', '1', now(), now(), '8', NULL),
('textcolor', @block_id, '1', '1', 'Text color', 'COLORPICKER', '1', now(), now(), '9', NULL);
");
//Components
$this->addSql("
SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='B31_notificationsbar');
INSERT INTO `std_blocks_components` (`machine_name`, `block_id`, `created_by`, `updated_by`, `component_type`, `settings`, `order_value`, `created_date`, `updated_date`, `name`, `is_repeatable`) VALUES
('text', @block_id, '1', '1', 'INPUT', NULL, '3', now(), now(), 'Text', '1'),
('label_url', @block_id, '1', '1', 'INPUT', NULL, '4', now(), now(), 'Label', '1'),
('url', @block_id, '1', '1', 'INPUT', NULL, '5', now(), now(), 'URL', '1'),
('target', @block_id, 1, 1, 'COMBO', '{\"data\": [{\"Self\": \"_self\"}, {\"New Page\": \"_blank\"}], \"type\": \"static\", \"default\": \"_self\"}', 10, now(), now(), 'Target', '1');
");
$this->addSql("
SET @id_ct_system=(SELECT id FROM std_content_types WHERE machine_name='system');
INSERT INTO `std_pages` (`template_id`,`created_by`,`updated_by`,`content_type`,`is_active`,`created_date`,`updated_date`,`order_value`,`publish_date`,`expire_date`,`name`,`layout`) VALUES
(NULL, 1, 1, @id_ct_system, 1, now(), now(), NULL, now(), NULL,'Barra de notificações', NULL);
SET @id_page_barra_notificacoes = LAST_INSERT_ID();
INSERT INTO `std_pages_content` (`page_id`, `language_code`, `created_by`, `updated_by`, `is_active`, `created_date`, `updated_date`, `title`, `url`, `canonical_url`, `content`) VALUES
(@id_page_barra_notificacoes, 'pt', 1, 1, 1, now(), now(), 'Barra de notificações', 'barra-de-notificacoes', '/pt/barra-de-notificacoes', '{\"fields\": {\"1\": {\"skin\": \"\", \"block\": \"B31_notificationsbar\", \"isMaster\": 0, \"settings\": {\"margin\": \"\", \"bgcolor\": \"rgb(52, 58, 64)\", \"padding\": \"\", \"container\": \"0\", \"textcolor\": \"rgb(255,255,255)\", \"expire_date\": \"\", \"extra_class\": \"\", \"publish_date\": \"\", \"disabled_block\": \"0\", \"extra_block_id\": \"\"}, \"blockname\": \"\", \"components\": [], \"repeatable\": [{\"url\": \"https://www.google.com\", \"text\": \"Text of notification \", \"target\": \"_self\", \"label_url\": \"link1\", \"settings_expire_date\": \"\", \"settings_publish_date\": \"\"}], \"templatesBlocksId\": 0}}}');
INSERT INTO `std_pages_pages` VALUES (NULL,@id_page_barra_notificacoes, 0, 1, @id_ct_system);
INSERT INTO `std_friendly_url` (`page_id`, `url`, `relation_tree`, `relation_id`, `language_code`, `is_canonical`)
VALUES (@id_page_barra_notificacoes, '/pt/barra-de-notificacoes', '[]', NULL, 'pt', 1);
INSERT 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
('notificationsbar_page', 1, 1, '', 'notificationsbar_page', 'notificationsbar_page', 'System', 'SELECT', 2, 0, 1, NOW(), NOW(), 'Barra de notificações', '{\"query\": \"select p.`name` as label,p.id as id from std_pages p INNER JOIN std_content_types sct ON p.content_type = sct.id where sct.machine_name IN ( \'system\')\"}', '');
");
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql("
SET @block_id=(SELECT id FROM std_blocks WHERE machine_name='B31_notificationsbar');
DELETE FROM `std_blocks_components` where machine_name IN ('text','label_url','url','target') and `block_id`= @block_id;
DELETE FROM `std_blocks_settings` where machine_name IN ('disabled_block','separator_styles','extra_block_id','extra_class','separator_spacings','margin','padding','container','bgcolor','textcolor') and `block_id`= @block_id;
DELETE FROM `std_blocks` where machine_name = 'B31_notificationsbar';
");
$this->addSql("
SET @id_page_barra_notificacoes = (SELECT id FROM std_pages WHERE name='Barra de notificações');
DELETE FROM `std_config` where machine_name IN ('notificationsbar_page');
DELETE FROM `std_friendly_url` where page_id = @id_page_barra_notificacoes;
DELETE FROM `std_pages_content` where page_id = @id_page_barra_notificacoes;
DELETE FROM `std_pages_pages` where page_id = @id_page_barra_notificacoes;
DELETE FROM `std_pages` where id = @id_page_barra_notificacoes;
");
}
}