migrations/Version20201223115043.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20201223115043 extends AbstractMigration
  10. {
  11.     public function getDescription() : string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema) : void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  19.         $this->addSql('ALTER TABLE std_web_users ADD logintoken VARCHAR(32) DEFAULT NULL, ADD activationkey VARCHAR(100) DEFAULT NULL, ADD facebook_id VARCHAR(255) DEFAULT NULL, ADD facebook_integration TINYINT(1) DEFAULT NULL, ADD google_id VARCHAR(255) DEFAULT NULL, ADD google_integration TINYINT(1) DEFAULT NULL, ADD terms_accepted_at DATETIME DEFAULT NULL;');
  20.         $this->addSql('ALTER TABLE `std_web_users` ADD COLUMN `phone` VARCHAR(20) NULL DEFAULT NULL COLLATE \'utf8mb4_unicode_ci\' AFTER `terms_accepted_at`,
  21.         ADD COLUMN `mobile` VARCHAR(20) NULL DEFAULT NULL AFTER `phone`; ');
  22.         $this->addSql('ALTER TABLE `std_web_users` CHANGE COLUMN `username` `username` VARCHAR(100) NULL COMMENT \'Username used to login\' COLLATE \'utf8mb4_unicode_ci\' AFTER `name`;');
  23.         $this->addSql('ALTER TABLE `std_web_users` CHANGE COLUMN `is_locked` `is_locked` TINYINT(1) NULL DEFAULT \'0\' COMMENT \'Flag to lock the user\' AFTER `language`,
  24.         CHANGE COLUMN `is_super_user` `is_super_user` TINYINT(1) NULL DEFAULT \'0\' COMMENT \'Flag indicating super user privileges\' AFTER `is_locked`,
  25.         CHANGE COLUMN `is_deleted` `is_deleted` TINYINT(1) NULL DEFAULT \'0\' COMMENT \'Flag that indicates the user has been deleted\' AFTER `is_super_user`,
  26.         CHANGE COLUMN `roles` `roles` JSON NULL AFTER `updated_date`;');
  27.         $this->addSql('ALTER TABLE `std_web_users`
  28.         ADD COLUMN `vat` VARCHAR(50) NULL DEFAULT NULL COMMENT \'User vat number\' AFTER `mobile`;');
  29.         $this->addSql("INSERT INTO `std_blocks` (`created_by`, `updated_by`, `machine_name`, `created_date`, `updated_date`, `name`, `settings`) VALUES ('1', '1', 'register_web_users', '2020-12-23 13:04:02', '2020-12-23 13:04:03', 'Registo Utilizador', '{\"isWebUsersRegistration\":true}');");
  30.         $this->addSql("
  31.         SET @id_block = LAST_INSERT_ID();
  32.         INSERT INTO `std_blocks_components` (`machine_name`, `block_id`, `created_by`, `updated_by`, `component_type`, `settings`, `order_value`, `is_active`, `created_date`, `updated_date`, `name`, `is_repeatable`) VALUES ('title', @id_block, 1, 1, 'INPUT', NULL, 1, 1, '2021-01-04 19:18:16', '2021-01-04 19:18:16', 'Title', 0);
  33.         INSERT INTO `std_blocks_components` (`machine_name`, `block_id`, `created_by`, `updated_by`, `component_type`, `settings`, `order_value`, `is_active`, `created_date`, `updated_date`, `name`, `is_repeatable`) VALUES ('address1', @id_block, 1, 1, 'CHECKBOX', NULL, 1, 1, '2021-01-04 19:18:16', '2021-01-04 19:18:16', 'Include Billing Address', 0);
  34.         INSERT INTO `std_blocks_components` (`machine_name`, `block_id`, `created_by`, `updated_by`, `component_type`, `settings`, `order_value`, `is_active`, `created_date`, `updated_date`, `name`, `is_repeatable`) VALUES ('address2', @id_block, 1, 1, 'CHECKBOX', NULL, 1, 1, '2021-01-04 19:18:16', '2021-01-04 19:18:16', 'Include Delivery Address', 0);
  35.         INSERT INTO `std_blocks_components` (`machine_name`, `block_id`, `created_by`, `updated_by`, `component_type`, `settings`, `order_value`, `is_active`, `created_date`, `updated_date`, `name`, `is_repeatable`) VALUES ('activation', @id_block, 1, 1, 'CHECKBOX', NULL, 1, 1, '2021-01-04 19:18:16', '2021-01-04 19:18:16', 'Require Activation', 0);
  36.         INSERT INTO `std_blocks_components` (`machine_name`, `block_id`, `created_by`, `updated_by`, `component_type`, `settings`, `order_value`, `is_active`, `created_date`, `updated_date`, `name`, `is_repeatable`) VALUES ('redirectto', @id_block, 1, 1, 'INPUT', NULL, 1, 1, '2021-01-04 19:18:16', '2021-01-04 19:18:16', 'Redirect to', 0);
  37.         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', @id_block, 1, 1, 'Disabled block', 'CHECKBOX', 1, '2020-06-22 15:27:32', '2020-06-22 15:27:32', -1, NULL);
  38.         
  39.         INSERT INTO `std_blocks` (`created_by`, `updated_by`, `machine_name`, `created_date`, `updated_date`, `name`) VALUES ('1', '1', 'login', '2021-01-07 15:42:47', '2021-01-07 15:42:47', 'Login Utilizadores');
  40.         SET @id_block = LAST_INSERT_ID();
  41.         INSERT INTO `std_blocks_components` (`machine_name`, `block_id`, `created_by`, `updated_by`, `component_type`, `order_value`, `created_date`, `updated_date`, `name`) VALUES ('redirectto', @id_block, '1', '1', 'INPUT', '1', '2021-01-07 15:46:30', '2021-01-07 15:46:31', 'Redirect to');
  42.         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', @id_block, 1, 1, 'Disabled block', 'CHECKBOX', 1, '2020-06-22 15:27:32', '2020-06-22 15:27:32', -1, NULL);
  43.         ");
  44.         
  45.     }
  46.     public function down(Schema $schema) : void
  47.     {
  48.         // this down() migration is auto-generated, please modify it to your needs
  49.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  50.         $this->addSql('ALTER TABLE `std_web_users` CHANGE COLUMN `is_locked` `is_locked` TINYINT(1) NOT NULL COMMENT \'Flag to lock the user\' AFTER `language`,
  51.         CHANGE COLUMN `is_super_user` `is_super_user` TINYINT(1) NOT NULL COMMENT \'Flag indicating super user privileges\' AFTER `is_locked`,
  52.         CHANGE COLUMN `is_deleted` `is_deleted` TINYINT(1) NOT NULL COMMENT \'Flag that indicates the user has been deleted\' AFTER `is_super_user`,
  53.         CHANGE COLUMN `roles` `roles` JSON NOT NULL AFTER `updated_date`;');
  54.         
  55.         $this->addSql('ALTER TABLE `std_web_users` CHANGE COLUMN `username` `username` VARCHAR(100) NOT NULL COMMENT \'Username used to login\' COLLATE \'utf8mb4_unicode_ci\' AFTER `name`;');
  56.         $this->addSql('ALTER TABLE std_web_users DROP logintoken, DROP activationkey, DROP facebook_id, DROP facebook_integration, DROP google_id, DROP google_integration, DROP terms_accepted_at, DROP phone, DROP mobile, DROP vat;');
  57.         $this->addSql("delete from std_blocks_components where block_id=(select id from std_blocks where machine_name='register_web_users')");
  58.         $this->addSql("delete from std_blocks_settings where block_id=(select id from std_blocks where machine_name='register_web_users')");
  59.         $this->addSql("delete from std_blocks where machine_name='register_web_users'");
  60.         $this->addSql("delete from std_blocks_components where block_id=(select id from std_blocks where machine_name='login')");
  61.         $this->addSql("delete from std_blocks_settings where block_id=(select id from std_blocks where machine_name='login')");
  62.         $this->addSql("delete from std_blocks where machine_name='login'");
  63.         
  64.     }
  65. }