<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20221020065709 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create the "job_status_log" table for logging when a job\'s status changes.';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE job_status_log (id INT AUTO_INCREMENT NOT NULL, job_id INT NOT NULL, user_id INT DEFAULT NULL, status INT DEFAULT 0 NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', updated_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_3B27A87ABE04EA9 (job_id), INDEX IDX_3B27A87AA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE job_status_log ADD CONSTRAINT FK_3B27A87ABE04EA9 FOREIGN KEY (job_id) REFERENCES job (id)');
$this->addSql('ALTER TABLE job_status_log ADD CONSTRAINT FK_3B27A87AA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE job_status_log DROP FOREIGN KEY FK_3B27A87ABE04EA9');
$this->addSql('ALTER TABLE job_status_log DROP FOREIGN KEY FK_3B27A87AA76ED395');
$this->addSql('DROP TABLE job_status_log');
}
}