Completed
Pull Request — develop (#189)
by Serhii
04:49 queued 02:35
created

Version20210504022820   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 21
loc 21
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescription() 4 4 1
A up() 9 9 1
A down() 3 3 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace DoctrineMigrations;
6
7
use Doctrine\DBAL\Schema\Schema;
8
use Doctrine\Migrations\AbstractMigration;
9
10 View Code Duplication
final class Version20210504022820 extends AbstractMigration
0 ignored issues
show
Duplication introduced by
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...
11
{
12
    public function getDescription() : string
13
    {
14
        return 'Employees Group table migration';
15
    }
16
17
    public function up(Schema $schema) : void
18
    {
19
        $this->addSql('CREATE TABLE employee_group_translation (id INT AUTO_INCREMENT NOT NULL, object_id INT DEFAULT NULL, locale VARCHAR(8) NOT NULL, field VARCHAR(32) NOT NULL, content LONGTEXT DEFAULT NULL, INDEX IDX_97B6048F232D562B (object_id), UNIQUE INDEX lookup_unique_employee_group_translation_idx (locale, object_id, field), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
20
        $this->addSql('CREATE TABLE employees_group (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, slug VARCHAR(255) NOT NULL, position INT NOT NULL, createdAt DATETIME NOT NULL, updatedAt DATETIME DEFAULT NULL, deletedAt DATETIME DEFAULT NULL, createdBy VARCHAR(255) DEFAULT NULL, updatedBy VARCHAR(255) DEFAULT NULL, deletedBy VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
21
        $this->addSql('ALTER TABLE employee_group_translation ADD CONSTRAINT FK_97B6048F232D562B FOREIGN KEY (object_id) REFERENCES employees_group (id) ON DELETE CASCADE');
22
        $this->addSql('ALTER TABLE employees ADD employeeGroup_id INT');
23
        $this->addSql('ALTER TABLE employees ADD CONSTRAINT FK_BA82C300F3260C63 FOREIGN KEY (employeeGroup_id) REFERENCES employees_group (id) ON DELETE SET NULL');
24
        $this->addSql('CREATE INDEX IDX_BA82C300F3260C63 ON employees (employeeGroup_id)');
25
    }
26
27
    public function down(Schema $schema) : void
28
    {
29
    }
30
}
31