|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SWP\Migrations; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\DBAL\Migrations\AbstractMigration; |
|
6
|
|
|
use Doctrine\DBAL\Schema\Schema; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Auto-generated Migration: Please modify to your needs! |
|
10
|
|
|
*/ |
|
11
|
|
|
class Version20170908083733 extends AbstractMigration |
|
|
|
|
|
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @param Schema $schema |
|
15
|
|
|
*/ |
|
16
|
|
View Code Duplication |
public function up(Schema $schema) |
|
|
|
|
|
|
17
|
|
|
{ |
|
18
|
|
|
// this up() migration is auto-generated, please modify it to your needs |
|
19
|
|
|
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); |
|
20
|
|
|
|
|
21
|
|
|
$this->addSql('CREATE SEQUENCE swp_event_category_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
|
22
|
|
|
$this->addSql('CREATE SEQUENCE swp_event_date_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
|
23
|
|
|
$this->addSql('CREATE SEQUENCE swp_event_location_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
|
24
|
|
|
$this->addSql('CREATE SEQUENCE swp_event_occur_status_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
|
25
|
|
|
$this->addSql('CREATE SEQUENCE swp_event_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
|
26
|
|
|
$this->addSql('CREATE TABLE swp_event_category (id INT NOT NULL, event_id INT NOT NULL, name VARCHAR(255) NOT NULL, qcode VARCHAR(255) NOT NULL, subject VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); |
|
27
|
|
|
$this->addSql('CREATE INDEX IDX_94BF293F71F7E88B ON swp_event_category (event_id)'); |
|
28
|
|
|
$this->addSql('CREATE TABLE swp_event_date (id INT NOT NULL, start_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, end_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, tz VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); |
|
29
|
|
|
$this->addSql('CREATE TABLE swp_event_location (id INT NOT NULL, event_id INT NOT NULL, name VARCHAR(255) NOT NULL, qcode VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); |
|
30
|
|
|
$this->addSql('CREATE INDEX IDX_CC6DB93571F7E88B ON swp_event_location (event_id)'); |
|
31
|
|
|
$this->addSql('CREATE TABLE swp_event_occur_status (id INT NOT NULL, name VARCHAR(255) NOT NULL, qcode VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); |
|
32
|
|
|
$this->addSql('CREATE TABLE swp_event (id INT NOT NULL, dates_id INT DEFAULT NULL, occur_status_id INT DEFAULT NULL, etag VARCHAR(255) NOT NULL, guid VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, version INT DEFAULT NULL, ingest_id VARCHAR(255) DEFAULT NULL, recurrence_id VARCHAR(255) DEFAULT NULL, original_creator VARCHAR(255) NOT NULL, version_creator VARCHAR(255) DEFAULT NULL, ingest_provider VARCHAR(255) DEFAULT NULL, original_source VARCHAR(255) DEFAULT NULL, ingest_provider_sequence VARCHAR(255) DEFAULT NULL, definition_short VARCHAR(255) DEFAULT NULL, definition_long VARCHAR(255) DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))'); |
|
33
|
|
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_658EE4843DA992C3 ON swp_event (dates_id)'); |
|
34
|
|
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_658EE4845DA64DFB ON swp_event (occur_status_id)'); |
|
35
|
|
|
$this->addSql('ALTER TABLE swp_event_category ADD CONSTRAINT FK_94BF293F71F7E88B FOREIGN KEY (event_id) REFERENCES swp_event (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
|
36
|
|
|
$this->addSql('ALTER TABLE swp_event_location ADD CONSTRAINT FK_CC6DB93571F7E88B FOREIGN KEY (event_id) REFERENCES swp_event (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
|
37
|
|
|
$this->addSql('ALTER TABLE swp_event ADD CONSTRAINT FK_658EE4843DA992C3 FOREIGN KEY (dates_id) REFERENCES swp_event_date (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
|
38
|
|
|
$this->addSql('ALTER TABLE swp_event ADD CONSTRAINT FK_658EE4845DA64DFB FOREIGN KEY (occur_status_id) REFERENCES swp_event_occur_status (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param Schema $schema |
|
43
|
|
|
*/ |
|
44
|
|
|
public function down(Schema $schema) |
|
45
|
|
|
{ |
|
46
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
|
47
|
|
|
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); |
|
48
|
|
|
|
|
49
|
|
|
$this->addSql('ALTER TABLE swp_event DROP CONSTRAINT FK_658EE4843DA992C3'); |
|
50
|
|
|
$this->addSql('ALTER TABLE swp_event DROP CONSTRAINT FK_658EE4845DA64DFB'); |
|
51
|
|
|
$this->addSql('ALTER TABLE swp_event_category DROP CONSTRAINT FK_94BF293F71F7E88B'); |
|
52
|
|
|
$this->addSql('ALTER TABLE swp_event_location DROP CONSTRAINT FK_CC6DB93571F7E88B'); |
|
53
|
|
|
$this->addSql('DROP SEQUENCE swp_event_category_id_seq CASCADE'); |
|
54
|
|
|
$this->addSql('DROP SEQUENCE swp_event_date_id_seq CASCADE'); |
|
55
|
|
|
$this->addSql('DROP SEQUENCE swp_event_location_id_seq CASCADE'); |
|
56
|
|
|
$this->addSql('DROP SEQUENCE swp_event_occur_status_id_seq CASCADE'); |
|
57
|
|
|
$this->addSql('DROP SEQUENCE swp_event_id_seq CASCADE'); |
|
58
|
|
|
$this->addSql('DROP TABLE swp_event_category'); |
|
59
|
|
|
$this->addSql('DROP TABLE swp_event_date'); |
|
60
|
|
|
$this->addSql('DROP TABLE swp_event_location'); |
|
61
|
|
|
$this->addSql('DROP TABLE swp_event_occur_status'); |
|
62
|
|
|
$this->addSql('DROP TABLE swp_event'); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.