Completed
Push — feature/test-php-7-2-in-travis ( 027341...a56bae )
by
unknown
05:31
created

Version20141112094457::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Surfnet\StepupMiddleware\Migrations;
4
5
use Doctrine\DBAL\Migrations\AbstractMigration;
6
use Doctrine\DBAL\Schema\Schema;
7
8
/**
9
 * Drops the UUID primary key, removes the UNIQUE constraint on (uuid, playhead) and make (uuid, playhead) the primary
10
 * key.
11
 */
12
class Version20141112094457 extends AbstractMigration
13
{
14
    public function up(Schema $schema)
15
    {
16
        // this up() migration is auto-generated, please modify it to your needs
17
        $this->abortIf(
18
            $this->connection->getDatabasePlatform()->getName() != 'mysql',
19
            'Migration can only be executed safely on \'mysql\'.'
20
        );
21
22
        $this->addSql('ALTER TABLE event_stream DROP PRIMARY KEY');
23
        $this->addSql('ALTER TABLE event_stream DROP INDEX unique_uuid_playhead');
24
        $this->addSql(
25
            'ALTER TABLE event_stream ADD CONSTRAINT pk_event_stream_uuid_playhead PRIMARY KEY (uuid, playhead)'
26
        );
27
    }
28
29
    public function down(Schema $schema)
30
    {
31
        // this down() migration is auto-generated, please modify it to your needs
32
        $this->abortIf(
33
            $this->connection->getDatabasePlatform()->getName() != 'mysql',
34
            'Migration can only be executed safely on \'mysql\'.'
35
        );
36
37
        $this->addSql('ALTER TABLE event_stream DROP PRIMARY KEY');
38
        $this->addSql("ALTER TABLE event_stream ADD UNIQUE INDEX unique_uuid_playhead (uuid, playhead)");
39
        $this->addSql('ALTER TABLE event_stream ADD CONSTRAINT pk_event_stream_uuid PRIMARY KEY (uuid)');
40
    }
41
}
42