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 Version20191216090544 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_redirect_route_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
21
|
|
|
$this->addSql('CREATE TABLE swp_redirect_route (id INT NOT NULL, route_source_id INT DEFAULT NULL, route_target_id INT DEFAULT NULL, host VARCHAR(255) NOT NULL, schemes TEXT NOT NULL, methods TEXT NOT NULL, defaults TEXT NOT NULL, requirements TEXT NOT NULL, options TEXT NOT NULL, condition_expr VARCHAR(255) DEFAULT NULL, variable_pattern VARCHAR(255) DEFAULT NULL, staticPrefix VARCHAR(255) DEFAULT NULL, route_name VARCHAR(255) DEFAULT NULL, uri VARCHAR(255) DEFAULT NULL, permanent BOOLEAN NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, tenant_code VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); |
22
|
|
|
$this->addSql('CREATE INDEX IDX_8681EEEE397EC969 ON swp_redirect_route (route_source_id)'); |
23
|
|
|
$this->addSql('CREATE INDEX IDX_8681EEEEB9CCDE6E ON swp_redirect_route (route_target_id)'); |
24
|
|
|
$this->addSql('CREATE INDEX swp_redirect_route_prefix ON swp_redirect_route (staticprefix, tenant_code)'); |
25
|
|
|
$this->addSql('COMMENT ON COLUMN swp_redirect_route.schemes IS \'(DC2Type:array)\''); |
26
|
|
|
$this->addSql('COMMENT ON COLUMN swp_redirect_route.methods IS \'(DC2Type:array)\''); |
27
|
|
|
$this->addSql('COMMENT ON COLUMN swp_redirect_route.defaults IS \'(DC2Type:array)\''); |
28
|
|
|
$this->addSql('COMMENT ON COLUMN swp_redirect_route.requirements IS \'(DC2Type:array)\''); |
29
|
|
|
$this->addSql('COMMENT ON COLUMN swp_redirect_route.options IS \'(DC2Type:array)\''); |
30
|
|
|
$this->addSql('ALTER TABLE swp_redirect_route ADD CONSTRAINT FK_8681EEEE397EC969 FOREIGN KEY (route_source_id) REFERENCES swp_route (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
31
|
|
|
$this->addSql('ALTER TABLE swp_redirect_route ADD CONSTRAINT FK_8681EEEEB9CCDE6E FOREIGN KEY (route_target_id) REFERENCES swp_route (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
32
|
|
|
$this->addSql('DROP INDEX prefix_idx'); |
33
|
|
|
$this->addSql('CREATE UNIQUE INDEX prefix_idx ON swp_route (staticprefix, tenant_code)'); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function down(Schema $schema): void |
37
|
|
|
{ |
38
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
39
|
|
|
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); |
40
|
|
|
|
41
|
|
|
$this->addSql('DROP SEQUENCE swp_redirect_route_id_seq CASCADE'); |
42
|
|
|
$this->addSql('DROP TABLE swp_redirect_route'); |
43
|
|
|
$this->addSql('DROP INDEX prefix_idx'); |
44
|
|
|
$this->addSql('CREATE INDEX prefix_idx ON swp_route (staticprefix)'); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|