point-tools/migrations/Version20160328060523.php

32 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2016-03-29 00:12:52 +00:00
<?php
2023-03-12 15:15:25 +00:00
declare(strict_types=1);
namespace DoctrineMigrations;
2016-03-29 00:12:52 +00:00
use Doctrine\DBAL\Schema\Schema;
2023-03-12 15:15:25 +00:00
use Doctrine\Migrations\AbstractMigration;
2016-03-29 00:12:52 +00:00
2023-03-12 15:15:25 +00:00
final class Version20160328060523 extends AbstractMigration
2016-03-29 00:12:52 +00:00
{
2023-03-12 15:15:25 +00:00
public function up(Schema $schema): void
2016-03-29 00:12:52 +00:00
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE SEQUENCE users.rename_log_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE users.rename_log (id INT NOT NULL, user_id INT NOT NULL, date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, old_login TEXT NOT NULL, new_login TEXT NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_10D64DDA76ED395 ON users.rename_log (user_id)');
$this->addSql('CREATE INDEX idx_rename_log_date ON users.rename_log (date)');
$this->addSql('CREATE INDEX idx_rename_log_old_login ON users.rename_log (old_login)');
$this->addSql('ALTER TABLE users.rename_log ADD CONSTRAINT FK_10D64DDA76ED395 FOREIGN KEY (user_id) REFERENCES users.users (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
}
2023-03-12 15:15:25 +00:00
public function down(Schema $schema): void
2016-03-29 00:12:52 +00:00
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('DROP SEQUENCE users.rename_log_id_seq CASCADE');
$this->addSql('DROP TABLE users.rename_log');
}
}