Completed
Pull Request — master (#3)
by Dejan
06:16
created

Version20170503123908   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 64
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
B up() 0 27 1
B down() 0 27 1
1
<?php
2
3
namespace Application\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 Version20170503123908 extends AbstractMigration
0 ignored issues
show
Deprecated Code introduced by
The class Doctrine\DBAL\Migrations\AbstractMigration has been deprecated: Please use Doctrine\Migrations\AbstractMigration ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

11
class Version20170503123908 extends /** @scrutinizer ignore-deprecated */ AbstractMigration
Loading history...
12
{
13
    /**
14
     * @param Schema $schema
15
     */
16
    public function up(Schema $schema)
17
    {
18
        // this up() migration is auto-generated, please modify it to your needs
19
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
20
21
        $this->addSql('ALTER TABLE community DROP FOREIGN KEY FK_1B604033F675F31B');
22
        $this->addSql('ALTER TABLE community_member DROP FOREIGN KEY FK_12E0F8BA76ED395');
23
        $this->addSql('ALTER TABLE thought DROP FOREIGN KEY FK_91BB9F6CF675F31B');
24
        $this->addSql('ALTER TABLE friendship_request DROP FOREIGN KEY FK_6CC48EE12130303A');
25
        $this->addSql('ALTER TABLE friendship_request DROP FOREIGN KEY FK_6CC48EE129F6EE60');
26
        $this->addSql('ALTER TABLE friendship DROP FOREIGN KEY FK_7234A45FA76ED395');
27
        $this->addSql('ALTER TABLE friendship DROP FOREIGN KEY FK_7234A45F6A5458E8');
28
29
        $this->addSql('ALTER TABLE community CHANGE author_id author_id CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\'');
30
        $this->addSql('ALTER TABLE community_member CHANGE user_id user_id CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\'');
31
        $this->addSql('ALTER TABLE user CHANGE id id CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\'');
32
        $this->addSql('ALTER TABLE thought CHANGE id id CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\', CHANGE author_id author_id CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\'');
33
        $this->addSql('ALTER TABLE friendship_request CHANGE from_user_id from_user_id CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\', CHANGE to_user_id to_user_id CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\'');
34
        $this->addSql('ALTER TABLE friendship CHANGE friend_id friend_id CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\', CHANGE user_id user_id CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\'');
35
36
        $this->addSql('ALTER TABLE community ADD CONSTRAINT FK_1B604033F675F31B FOREIGN KEY (author_id) REFERENCES user (id)');
37
        $this->addSql('ALTER TABLE community_member ADD CONSTRAINT FK_12E0F8BA76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
38
        $this->addSql('ALTER TABLE thought ADD CONSTRAINT FK_91BB9F6CF675F31B FOREIGN KEY (author_id) REFERENCES user (id)');
39
        $this->addSql('ALTER TABLE friendship_request ADD CONSTRAINT FK_6CC48EE12130303A FOREIGN KEY (from_user_id) REFERENCES user (id) ON DELETE CASCADE');
40
        $this->addSql('ALTER TABLE friendship_request ADD CONSTRAINT FK_6CC48EE129F6EE60 FOREIGN KEY (to_user_id) REFERENCES user (id) ON DELETE CASCADE');
41
        $this->addSql('ALTER TABLE friendship ADD CONSTRAINT FK_7234A45FA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
42
        $this->addSql('ALTER TABLE friendship ADD CONSTRAINT FK_7234A45F6A5458E8 FOREIGN KEY (friend_id) REFERENCES user (id)');
43
    }
44
45
    /**
46
     * @param Schema $schema
47
     */
48
    public function down(Schema $schema)
49
    {
50
        // this down() migration is auto-generated, please modify it to your needs
51
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
52
53
        $this->addSql('ALTER TABLE community DROP FOREIGN KEY FK_1B604033F675F31B');
54
        $this->addSql('ALTER TABLE community_member DROP FOREIGN KEY FK_12E0F8BA76ED395');
55
        $this->addSql('ALTER TABLE thought DROP FOREIGN KEY FK_91BB9F6CF675F31B');
56
        $this->addSql('ALTER TABLE friendship_request DROP FOREIGN KEY FK_6CC48EE12130303A');
57
        $this->addSql('ALTER TABLE friendship_request DROP FOREIGN KEY FK_6CC48EE129F6EE60');
58
        $this->addSql('ALTER TABLE friendship DROP FOREIGN KEY FK_7234A45FA76ED395');
59
        $this->addSql('ALTER TABLE friendship DROP FOREIGN KEY FK_7234A45F6A5458E8');
60
61
        $this->addSql('ALTER TABLE community CHANGE author_id author_id INT NOT NULL');
62
        $this->addSql('ALTER TABLE community_member CHANGE user_id user_id INT NOT NULL');
63
        $this->addSql('ALTER TABLE friendship CHANGE user_id user_id INT NOT NULL, CHANGE friend_id friend_id INT NOT NULL');
64
        $this->addSql('ALTER TABLE friendship_request CHANGE from_user_id from_user_id INT NOT NULL, CHANGE to_user_id to_user_id INT NOT NULL');
65
        $this->addSql('ALTER TABLE thought CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE author_id author_id INT NOT NULL');
66
        $this->addSql('ALTER TABLE user CHANGE id id INT AUTO_INCREMENT NOT NULL');
67
68
        $this->addSql('ALTER TABLE community ADD CONSTRAINT FK_1B604033F675F31B FOREIGN KEY (author_id) REFERENCES user (id)');
69
        $this->addSql('ALTER TABLE community_member ADD CONSTRAINT FK_12E0F8BA76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
70
        $this->addSql('ALTER TABLE thought ADD CONSTRAINT FK_91BB9F6CF675F31B FOREIGN KEY (author_id) REFERENCES user (id)');
71
        $this->addSql('ALTER TABLE friendship_request ADD CONSTRAINT FK_6CC48EE12130303A FOREIGN KEY (from_user_id) REFERENCES user (id) ON DELETE CASCADE');
72
        $this->addSql('ALTER TABLE friendship_request ADD CONSTRAINT FK_6CC48EE129F6EE60 FOREIGN KEY (to_user_id) REFERENCES user (id) ON DELETE CASCADE');
73
        $this->addSql('ALTER TABLE friendship ADD CONSTRAINT FK_7234A45FA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
74
        $this->addSql('ALTER TABLE friendship ADD CONSTRAINT FK_7234A45F6A5458E8 FOREIGN KEY (friend_id) REFERENCES user (id)');
75
    }
76
}
77