migrations/Version20230724163325.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 Version20230724163325 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->addSql("CREATE TABLE IF NOT EXISTS `std_diary` (
  19.             `type` enum('users','roles','schedulertask') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  20.             `subtype` enum('usercreated','usermodified','userdeleted','userroleadded','userroledeleted','schedulertaskcreated','schedulertaskmodified','schedulertaskdeleted','schedulertaskstarted','schedulertaskended','schedulertaskplayed','schedulertaskstopped','acceptedtermsconditions') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  21.             `id_totype` int NOT NULL,
  22.             `id_tosubtype` int NOT NULL,
  23.             `color` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  24.             `icon` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  25.             `text` text COLLATE utf8mb4_general_ci,
  26.             `created_by` int unsigned DEFAULT NULL,
  27.             `created_date` datetime DEFAULT NULL,
  28.             `updated_by` int unsigned DEFAULT NULL,
  29.             `updated_date` datetime DEFAULT NULL,
  30.             `ID` int unsigned NOT NULL AUTO_INCREMENT,
  31.             PRIMARY KEY (`ID`),
  32.             KEY `FK_CreatedByUser` (`created_by`),
  33.             KEY `FK_UpdatedByUser` (`updated_by`),
  34.             CONSTRAINT `FK_CreatedByUser` FOREIGN KEY (`created_by`) REFERENCES `std_users` (`id`),
  35.             CONSTRAINT `FK_UpdatedByUser` FOREIGN KEY (`updated_by`) REFERENCES `std_users` (`id`)
  36.           ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;");
  37.           $this->addSql("CREATE TABLE IF NOT EXISTS `std_scheduler_commands` (
  38.             `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Command unique identifier',
  39.             `machine_name` varchar(50) NOT NULL COMMENT 'Command machine name',
  40.             `name` varchar(50) DEFAULT NULL COMMENT 'Command name',
  41.             `description` text COMMENT 'Command description',
  42.             `is_active` tinyint(1) DEFAULT '1' COMMENT 'Flag that indicates if the command is active',
  43.             `is_stoppable` tinyint(1) DEFAULT '0' COMMENT 'Flag that indictes if command can be stopped manually while running',
  44.             PRIMARY KEY (`id`),
  45.             UNIQUE KEY `machine_name` (`machine_name`)
  46.           ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb3;");
  47.           $this->addSql("CREATE TABLE IF NOT EXISTS `std_scheduler_tasks` (
  48.             `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Task unique identifier',
  49.             `created_by` int unsigned NOT NULL COMMENT 'Unique identifier',
  50.             `updated_by` int unsigned NOT NULL COMMENT 'Unique identifier',
  51.             `scheduler_command_id` int unsigned NOT NULL COMMENT 'Command unique identifier',
  52.             `name` varchar(50) NOT NULL COMMENT 'Task name',
  53.             `description` text COMMENT 'Task description',
  54.             `cron_expression` varchar(50) DEFAULT NULL COMMENT 'How often the task should be performed (ex: * * * * *)',
  55.             `arguments` text COMMENT 'Symfony command arguments. New line delimited',
  56.             `parameters` text COMMENT 'Symfony command options. New line delimited',
  57.             `status` smallint DEFAULT NULL COMMENT 'null - Never executed, 0 - running, -1 - error, 1 - success, 2 stopped',
  58.             `progress` smallint DEFAULT NULL COMMENT 'Progress Percentage',
  59.             `progress_info` varchar(500) DEFAULT NULL COMMENT 'Progress info',
  60.             `execute_at` datetime DEFAULT NULL COMMENT 'Next date on which the task should be performed',
  61.             `started_at` datetime DEFAULT NULL COMMENT 'Task started at',
  62.             `finished_at` datetime DEFAULT NULL COMMENT 'Task finished at',
  63.             `force_stop` tinyint(1) DEFAULT '0' COMMENT 'Flag that indictes the task should stop immediatly',
  64.             `force_start` tinyint(1) DEFAULT '0' COMMENT 'Flag that indictes the task should start immediatly',
  65.             `is_active` tinyint(1) DEFAULT '1' COMMENT 'Flag that indicates if the task is active',
  66.             `is_deleted` tinyint(1) DEFAULT '0' COMMENT 'Flag that indicates if the task is deleted',
  67.             `created_date` datetime DEFAULT NULL COMMENT 'Date and time of the record creation',
  68.             `updated_date` datetime DEFAULT NULL COMMENT 'Date and time the record was last updated',
  69.             PRIMARY KEY (`id`),
  70.             KEY `FK_std_scheduler_tasks_std_users` (`created_by`),
  71.             KEY `FK_std_scheduler_tasks_std_users_2` (`updated_by`),
  72.             KEY `FK_std_scheduler_tasks_std_scheduler_commands` (`scheduler_command_id`),
  73.             CONSTRAINT `FK_std_scheduler_tasks_std_scheduler_commands` FOREIGN KEY (`scheduler_command_id`) REFERENCES `std_scheduler_commands` (`id`),
  74.             CONSTRAINT `FK_std_scheduler_tasks_std_users` FOREIGN KEY (`created_by`) REFERENCES `std_users` (`id`),
  75.             CONSTRAINT `FK_std_scheduler_tasks_std_users_2` FOREIGN KEY (`updated_by`) REFERENCES `std_users` (`id`)
  76.           ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb3;");
  77.           $this->addSql("INSERT INTO `std_scheduler_commands` (`machine_name`, `name`, `description`, `is_active`, `is_stoppable`) VALUES ('app:example-command', 'Example Command', 'Arguments:\r\n   text                                       Texto a imprimir\r\n\r\nOptions:\r\n      --iterations=VALUE         (integer) Quantas vezes é para imprimir o texto\r\n      --sleep=VALUE                (integer) Quantos segundos se espera entre cada print\r\n\r\nHelp:\r\n  Commando de exemplo que serve apenas de demonstração\r\n  Este comando escreve determinado texto. Pode-se definir o texto, o número de vezes que escreve e de quanto em quanto tempo escreve.\r\n  O Commando actualiza o progresso e isso fica visivel no backoffice no task scheduler', 1, 1);");
  78.     }
  79.     public function down(Schema $schema): void
  80.     {
  81.         // this down() migration is auto-generated, please modify it to your needs
  82.         
  83.         $this->addSql("DROP TABLE IF EXISTS `std_scheduler_tasks`;");
  84.         
  85.         $this->addSql("DROP TABLE IF EXISTS `std_scheduler_commands`;");
  86.         
  87.         $this->addSql("DROP TABLE IF EXISTS `std_diary`;");
  88.     }
  89. }