Completed
Push — development ( 1b87d2...43bb99 )
by Thomas
06:02
created

htdocs/app/Migrations/Version20160607213541.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Application\Migrations;
4
5
use Doctrine\DBAL\Migrations\AbstractMigration;
6
use Doctrine\DBAL\Schema\Schema;
7
8
/**
9
 * Migration to create field_note table and add foreign keys.
10
 */
11 View Code Duplication
class Version20160607213541 extends AbstractMigration
0 ignored issues
show
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
{
13
    /**
14
     * @param Schema $schema
15
     */
16
    public function up(Schema $schema)
17
    {
18
        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
19
20
        $this->addSql('CREATE TABLE field_note (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, geocache_id INT DEFAULT NULL, type SMALLINT NOT NULL, date DATETIME NOT NULL, text VARCHAR(255) DEFAULT NULL, INDEX IDX_DC7193AEA76ED395 (user_id), INDEX IDX_DC7193AE67030974 (geocache_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ENGINE = MyISAM');
21
        $this->addSql('ALTER TABLE field_note ADD CONSTRAINT FK_DC7193AEA76ED395 FOREIGN KEY (user_id) REFERENCES user (user_id) ON DELETE CASCADE');
22
        $this->addSql('ALTER TABLE field_note ADD CONSTRAINT FK_DC7193AE67030974 FOREIGN KEY (geocache_id) REFERENCES caches (cache_id) ON DELETE CASCADE');
23
    }
24
25
    /**
26
     * @param Schema $schema
27
     */
28
    public function down(Schema $schema)
29
    {
30
        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
31
32
        $this->addSql('DROP TABLE field_note');
33
    }
34
}
35