2017-11-04 19:38:38 +00:00
|
|
|
<?php
|
|
|
|
|
2023-03-12 15:15:25 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace DoctrineMigrations;
|
2017-11-04 19:38:38 +00:00
|
|
|
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
2023-03-12 15:15:25 +00:00
|
|
|
use Doctrine\Migrations\AbstractMigration;
|
2017-11-04 19:38:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* New fields for User entity: 'public' and 'whitelistOnly' (privacy support)
|
|
|
|
*/
|
2023-03-12 15:15:25 +00:00
|
|
|
final class Version20171104182713 extends AbstractMigration
|
2017-11-04 19:38:38 +00:00
|
|
|
{
|
2023-03-12 15:15:25 +00:00
|
|
|
public function up(Schema $schema): void
|
2017-11-04 19:38:38 +00:00
|
|
|
{
|
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
|
|
|
|
|
|
|
$this->addSql('ALTER TABLE users.users ADD public BOOLEAN DEFAULT FALSE NOT NULL');
|
|
|
|
$this->addSql('ALTER TABLE users.users ADD whitelist_only BOOLEAN DEFAULT FALSE NOT NULL');
|
|
|
|
$this->addSql('CREATE INDEX idx_user_public ON users.users (public)');
|
|
|
|
$this->addSql('CREATE INDEX idx_user_removed ON users.users (is_removed)');
|
|
|
|
}
|
|
|
|
|
2023-03-12 15:15:25 +00:00
|
|
|
public function down(Schema $schema): void
|
2017-11-04 19:38:38 +00:00
|
|
|
{
|
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
|
|
|
|
|
|
|
$this->addSql('DROP INDEX users.idx_user_public');
|
|
|
|
$this->addSql('DROP INDEX users.idx_user_removed');
|
|
|
|
$this->addSql('ALTER TABLE users.users DROP public');
|
|
|
|
$this->addSql('ALTER TABLE users.users DROP whitelist_only');
|
|
|
|
}
|
|
|
|
}
|