46 lines
2.8 KiB
PHP
46 lines
2.8 KiB
PHP
<?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 Version20260401073322 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 service_log (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, from_status VARCHAR(20) NOT NULL, to_status VARCHAR(20) NOT NULL, source VARCHAR(50) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, service_id INT NOT NULL, changed_by_id INT DEFAULT NULL, PRIMARY KEY (id))');
|
|
$this->addSql('CREATE INDEX IDX_AD6F1BB2ED5CA9E6 ON service_log (service_id)');
|
|
$this->addSql('CREATE INDEX IDX_AD6F1BB2828AD0A0 ON service_log (changed_by_id)');
|
|
$this->addSql('CREATE TABLE service_message (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, title VARCHAR(255) NOT NULL, content TEXT NOT NULL, severity VARCHAR(20) NOT NULL, is_active BOOLEAN NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, resolved_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, service_id INT NOT NULL, author_id INT DEFAULT NULL, PRIMARY KEY (id))');
|
|
$this->addSql('CREATE INDEX IDX_793962E3ED5CA9E6 ON service_message (service_id)');
|
|
$this->addSql('CREATE INDEX IDX_793962E3F675F31B ON service_message (author_id)');
|
|
$this->addSql('ALTER TABLE service_log ADD CONSTRAINT FK_AD6F1BB2ED5CA9E6 FOREIGN KEY (service_id) REFERENCES service (id) ON DELETE CASCADE NOT DEFERRABLE');
|
|
$this->addSql('ALTER TABLE service_log ADD CONSTRAINT FK_AD6F1BB2828AD0A0 FOREIGN KEY (changed_by_id) REFERENCES "user" (id) ON DELETE SET NULL NOT DEFERRABLE');
|
|
$this->addSql('ALTER TABLE service_message ADD CONSTRAINT FK_793962E3ED5CA9E6 FOREIGN KEY (service_id) REFERENCES service (id) ON DELETE CASCADE NOT DEFERRABLE');
|
|
$this->addSql('ALTER TABLE service_message ADD CONSTRAINT FK_793962E3F675F31B FOREIGN KEY (author_id) REFERENCES "user" (id) ON DELETE SET NULL NOT DEFERRABLE');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
// this down() migration is auto-generated, please modify it to your needs
|
|
$this->addSql('ALTER TABLE service_log DROP CONSTRAINT FK_AD6F1BB2ED5CA9E6');
|
|
$this->addSql('ALTER TABLE service_log DROP CONSTRAINT FK_AD6F1BB2828AD0A0');
|
|
$this->addSql('ALTER TABLE service_message DROP CONSTRAINT FK_793962E3ED5CA9E6');
|
|
$this->addSql('ALTER TABLE service_message DROP CONSTRAINT FK_793962E3F675F31B');
|
|
$this->addSql('DROP TABLE service_log');
|
|
$this->addSql('DROP TABLE service_message');
|
|
}
|
|
}
|