64 lines
2.6 KiB
PHP
64 lines
2.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
final class Version20260423100000 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Create RemotePC and AgentQueue entities for UDS RemotePC integration';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$this->addSql('CREATE TABLE remote_pc (
|
|
id INT AUTO_INCREMENT NOT NULL,
|
|
client_id INT NOT NULL,
|
|
reserved_until DATETIME DEFAULT NULL,
|
|
url_login VARCHAR(512) DEFAULT NULL,
|
|
url_logout VARCHAR(512) DEFAULT NULL,
|
|
uuid VARCHAR(255) NOT NULL,
|
|
migration_id VARCHAR(255) DEFAULT NULL,
|
|
created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\',
|
|
updated_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\',
|
|
created_by VARCHAR(255) DEFAULT NULL,
|
|
updated_by VARCHAR(255) DEFAULT NULL,
|
|
UNIQUE INDEX UNIQ_REMOTE_PC_UUID (uuid),
|
|
UNIQUE INDEX UNIQ_REMOTE_PC_CLIENT (client_id),
|
|
PRIMARY KEY(id)
|
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
|
|
|
$this->addSql('CREATE TABLE agent_queue (
|
|
id INT AUTO_INCREMENT NOT NULL,
|
|
client_id INT NOT NULL,
|
|
exec_time DATETIME NOT NULL,
|
|
operation VARCHAR(32) NOT NULL,
|
|
uuid VARCHAR(255) NOT NULL,
|
|
migration_id VARCHAR(255) DEFAULT NULL,
|
|
created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\',
|
|
updated_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\',
|
|
created_by VARCHAR(255) DEFAULT NULL,
|
|
updated_by VARCHAR(255) DEFAULT NULL,
|
|
UNIQUE INDEX UNIQ_AGENT_QUEUE_UUID (uuid),
|
|
INDEX IDX_AGENT_QUEUE_CLIENT (client_id),
|
|
PRIMARY KEY(id)
|
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
|
|
|
$this->addSql('ALTER TABLE remote_pc ADD CONSTRAINT FK_REMOTE_PC_CLIENT FOREIGN KEY (client_id) REFERENCES client (id) ON DELETE CASCADE');
|
|
$this->addSql('ALTER TABLE agent_queue ADD CONSTRAINT FK_AGENT_QUEUE_CLIENT FOREIGN KEY (client_id) REFERENCES client (id) ON DELETE CASCADE');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
$this->addSql('ALTER TABLE remote_pc DROP FOREIGN KEY FK_REMOTE_PC_CLIENT');
|
|
$this->addSql('ALTER TABLE agent_queue DROP FOREIGN KEY FK_AGENT_QUEUE_CLIENT');
|
|
$this->addSql('DROP TABLE remote_pc');
|
|
$this->addSql('DROP TABLE agent_queue');
|
|
}
|
|
}
|