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 add column admin_password and roles to user table. |
||
10 | */ |
||
11 | View Code Duplication | class Version20170221215409 extends AbstractMigration |
|
0 ignored issues
–
show
|
|||
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('ALTER TABLE `user` ADD `admin_password` BINARY(60) NULL DEFAULT NULL AFTER `password`'); |
||
21 | $this->addSql('ALTER TABLE `user` ADD `roles` TEXT NULL AFTER `admin_password`;'); |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * @param Schema $schema |
||
26 | */ |
||
27 | public function down(Schema $schema) |
||
28 | { |
||
29 | $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
||
30 | |||
31 | $this->addSql('ALTER TABLE `user` DROP `admin_password`'); |
||
32 | $this->addSql('ALTER TABLE `user` DROP `roles`'); |
||
33 | } |
||
34 | } |
||
35 |
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.