|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace SWP\Migrations; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\DBAL\Schema\Schema; |
|
8
|
|
|
use Doctrine\Migrations\AbstractMigration; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Auto-generated Migration: Please modify to your needs! |
|
12
|
|
|
*/ |
|
13
|
|
View Code Duplication |
final class Version20200331075145 extends AbstractMigration |
|
14
|
|
|
{ |
|
15
|
|
|
public function up(Schema $schema): void |
|
16
|
|
|
{ |
|
17
|
|
|
// this up() migration is auto-generated, please modify it to your needs |
|
18
|
|
|
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); |
|
19
|
|
|
|
|
20
|
|
|
$this->addSql('CREATE SEQUENCE swp_apple_news_config_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
|
21
|
|
|
$this->addSql('CREATE SEQUENCE swp_article_apple_news_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
|
22
|
|
|
$this->addSql('CREATE TABLE swp_apple_news_config (id INT NOT NULL, tenant_id INT DEFAULT NULL, channel_id VARCHAR(255) NOT NULL, api_key_id VARCHAR(255) NOT NULL, api_key_secret VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); |
|
23
|
|
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_C308F3089033212A ON swp_apple_news_config (tenant_id)'); |
|
24
|
|
|
$this->addSql('CREATE TABLE swp_article_apple_news (id INT NOT NULL, apple_news_article_id VARCHAR(255) NOT NULL, revision_id VARCHAR(255) NOT NULL, share_url VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); |
|
25
|
|
|
$this->addSql('ALTER TABLE swp_apple_news_config ADD CONSTRAINT FK_C308F3089033212A FOREIGN KEY (tenant_id) REFERENCES swp_tenant (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
|
26
|
|
|
$this->addSql('ALTER TABLE swp_article ADD apple_news_article_id INT DEFAULT NULL'); |
|
27
|
|
|
$this->addSql('ALTER TABLE swp_article ADD is_published_to_apple_news BOOLEAN DEFAULT \'false\' NOT NULL'); |
|
28
|
|
|
$this->addSql('ALTER TABLE swp_article ADD CONSTRAINT FK_FB21E858790923B6 FOREIGN KEY (apple_news_article_id) REFERENCES swp_article_apple_news (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE'); |
|
29
|
|
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_FB21E858790923B6 ON swp_article (apple_news_article_id)'); |
|
30
|
|
|
$this->addSql('ALTER TABLE swp_publish_destination ADD is_published_to_apple_news BOOLEAN DEFAULT \'false\' NOT NULL'); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function down(Schema $schema): void |
|
34
|
|
|
{ |
|
35
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
|
36
|
|
|
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); |
|
37
|
|
|
|
|
38
|
|
|
$this->addSql('ALTER TABLE swp_article DROP CONSTRAINT FK_FB21E858790923B6'); |
|
39
|
|
|
$this->addSql('DROP SEQUENCE swp_apple_news_config_id_seq CASCADE'); |
|
40
|
|
|
$this->addSql('DROP SEQUENCE swp_article_apple_news_id_seq CASCADE'); |
|
41
|
|
|
$this->addSql('DROP TABLE swp_apple_news_config'); |
|
42
|
|
|
$this->addSql('DROP TABLE swp_article_apple_news'); |
|
43
|
|
|
$this->addSql('DROP INDEX UNIQ_FB21E858790923B6'); |
|
44
|
|
|
$this->addSql('ALTER TABLE swp_article DROP apple_news_article_id'); |
|
45
|
|
|
$this->addSql('ALTER TABLE swp_article DROP is_published_to_apple_news'); |
|
46
|
|
|
$this->addSql('ALTER TABLE swp_publish_destination DROP is_published_to_apple_news'); |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|