Failed Conditions
Push — master ( 2695cf...ba7e19 )
by Sylvain
08:48 queued 11s
created

Version20210707145050::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 9
ccs 0
cts 5
cp 0
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Migration;
6
7
use Doctrine\DBAL\Schema\Schema;
8
use Ecodev\Felix\Migration\IrreversibleMigration;
9
10
class Version20210707145050 extends IrreversibleMigration
11
{
12
    public function up(Schema $schema): void
13
    {
14
        // Add new booking types to enum
15
        $this->addSql('ALTER TABLE bookable MODIFY booking_type ENUM(\'self_approved\', \'admin_approved\', \'application\', \'admin_assigned\', \'admin_only\', \'mandatory\') DEFAULT \'self_approved\' NOT NULL');
16
        // Migrate values of existing booking types
17
        $this->addSql('UPDATE bookable SET booking_type = \'application\' WHERE booking_type = \'admin_approved\'');
18
        $this->addSql('UPDATE bookable SET booking_type = \'admin_assigned\' WHERE booking_type = \'admin_only\'');
19
        // Remove old booking types from enum
20
        $this->addSql('ALTER TABLE bookable MODIFY booking_type ENUM(\'self_approved\', \'application\', \'admin_assigned\', \'mandatory\') DEFAULT \'self_approved\' NOT NULL COMMENT \'(DC2Type:BookingType)\'');
21
    }
22
}
23