40 lines
1.7 KiB
PHP
40 lines
1.7 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 Version20260514054123 extends AbstractMigration
|
||
|
|
{
|
||
|
|
public function getDescription(): string
|
||
|
|
{
|
||
|
|
return '';
|
||
|
|
}
|
||
|
|
|
||
|
|
public function up(Schema $schema): void
|
||
|
|
{
|
||
|
|
$this->addSql('CREATE SCHEMA IF NOT EXISTS logs');
|
||
|
|
$this->addSql('CREATE SCHEMA IF NOT EXISTS logs_archive');
|
||
|
|
$this->addSql('CREATE SEQUENCE logs.log_entries_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||
|
|
$this->addSql('CREATE TABLE logs.log_entries (id BIGINT NOT NULL, channel VARCHAR(50) NOT NULL, level INT NOT NULL, level_name VARCHAR(50) NOT NULL, message TEXT NOT NULL, context JSON NOT NULL, extra JSON NOT NULL, logged_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
|
||
|
|
$this->addSql('COMMENT ON COLUMN logs.log_entries.logged_at IS \'(DC2Type:datetime_immutable)\'');
|
||
|
|
$this->addSql('CREATE INDEX idx_log_entries_channel ON logs.log_entries (channel)');
|
||
|
|
$this->addSql('CREATE INDEX idx_log_entries_level ON logs.log_entries (level)');
|
||
|
|
$this->addSql('CREATE INDEX idx_log_entries_logged_at ON logs.log_entries (logged_at)');
|
||
|
|
$this->addSql('ALTER SEQUENCE logs.log_entries_id_seq OWNED BY logs.log_entries.id');
|
||
|
|
$this->addSql('ALTER TABLE logs.log_entries ALTER id SET DEFAULT nextval(\'logs.log_entries_id_seq\')');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function down(Schema $schema): void
|
||
|
|
{
|
||
|
|
$this->addSql('DROP TABLE logs.log_entries');
|
||
|
|
$this->addSql('DROP SEQUENCE logs.log_entries_id_seq CASCADE');
|
||
|
|
}
|
||
|
|
}
|