<?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 Version20230724163325 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql("CREATE TABLE IF NOT EXISTS `std_diary` (
`type` enum('users','roles','schedulertask') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
`subtype` enum('usercreated','usermodified','userdeleted','userroleadded','userroledeleted','schedulertaskcreated','schedulertaskmodified','schedulertaskdeleted','schedulertaskstarted','schedulertaskended','schedulertaskplayed','schedulertaskstopped','acceptedtermsconditions') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
`id_totype` int NOT NULL,
`id_tosubtype` int NOT NULL,
`color` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
`icon` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
`text` text COLLATE utf8mb4_general_ci,
`created_by` int unsigned DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`updated_by` int unsigned DEFAULT NULL,
`updated_date` datetime DEFAULT NULL,
`ID` int unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`ID`),
KEY `FK_CreatedByUser` (`created_by`),
KEY `FK_UpdatedByUser` (`updated_by`),
CONSTRAINT `FK_CreatedByUser` FOREIGN KEY (`created_by`) REFERENCES `std_users` (`id`),
CONSTRAINT `FK_UpdatedByUser` FOREIGN KEY (`updated_by`) REFERENCES `std_users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;");
$this->addSql("CREATE TABLE IF NOT EXISTS `std_scheduler_commands` (
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Command unique identifier',
`machine_name` varchar(50) NOT NULL COMMENT 'Command machine name',
`name` varchar(50) DEFAULT NULL COMMENT 'Command name',
`description` text COMMENT 'Command description',
`is_active` tinyint(1) DEFAULT '1' COMMENT 'Flag that indicates if the command is active',
`is_stoppable` tinyint(1) DEFAULT '0' COMMENT 'Flag that indictes if command can be stopped manually while running',
PRIMARY KEY (`id`),
UNIQUE KEY `machine_name` (`machine_name`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb3;");
$this->addSql("CREATE TABLE IF NOT EXISTS `std_scheduler_tasks` (
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Task unique identifier',
`created_by` int unsigned NOT NULL COMMENT 'Unique identifier',
`updated_by` int unsigned NOT NULL COMMENT 'Unique identifier',
`scheduler_command_id` int unsigned NOT NULL COMMENT 'Command unique identifier',
`name` varchar(50) NOT NULL COMMENT 'Task name',
`description` text COMMENT 'Task description',
`cron_expression` varchar(50) DEFAULT NULL COMMENT 'How often the task should be performed (ex: * * * * *)',
`arguments` text COMMENT 'Symfony command arguments. New line delimited',
`parameters` text COMMENT 'Symfony command options. New line delimited',
`status` smallint DEFAULT NULL COMMENT 'null - Never executed, 0 - running, -1 - error, 1 - success, 2 stopped',
`progress` smallint DEFAULT NULL COMMENT 'Progress Percentage',
`progress_info` varchar(500) DEFAULT NULL COMMENT 'Progress info',
`execute_at` datetime DEFAULT NULL COMMENT 'Next date on which the task should be performed',
`started_at` datetime DEFAULT NULL COMMENT 'Task started at',
`finished_at` datetime DEFAULT NULL COMMENT 'Task finished at',
`force_stop` tinyint(1) DEFAULT '0' COMMENT 'Flag that indictes the task should stop immediatly',
`force_start` tinyint(1) DEFAULT '0' COMMENT 'Flag that indictes the task should start immediatly',
`is_active` tinyint(1) DEFAULT '1' COMMENT 'Flag that indicates if the task is active',
`is_deleted` tinyint(1) DEFAULT '0' COMMENT 'Flag that indicates if the task is deleted',
`created_date` datetime DEFAULT NULL COMMENT 'Date and time of the record creation',
`updated_date` datetime DEFAULT NULL COMMENT 'Date and time the record was last updated',
PRIMARY KEY (`id`),
KEY `FK_std_scheduler_tasks_std_users` (`created_by`),
KEY `FK_std_scheduler_tasks_std_users_2` (`updated_by`),
KEY `FK_std_scheduler_tasks_std_scheduler_commands` (`scheduler_command_id`),
CONSTRAINT `FK_std_scheduler_tasks_std_scheduler_commands` FOREIGN KEY (`scheduler_command_id`) REFERENCES `std_scheduler_commands` (`id`),
CONSTRAINT `FK_std_scheduler_tasks_std_users` FOREIGN KEY (`created_by`) REFERENCES `std_users` (`id`),
CONSTRAINT `FK_std_scheduler_tasks_std_users_2` FOREIGN KEY (`updated_by`) REFERENCES `std_users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb3;");
$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);");
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql("DROP TABLE IF EXISTS `std_scheduler_tasks`;");
$this->addSql("DROP TABLE IF EXISTS `std_scheduler_commands`;");
$this->addSql("DROP TABLE IF EXISTS `std_diary`;");
}
}