Passed
Pull Request — master (#6421)
by Yannick
27:19 queued 14:40
created

Version20250630093000::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 20
nc 1
nop 1
dl 0
loc 20
rs 9.6
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
8
9
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
10
use Doctrine\DBAL\Schema\Schema;
11
12
class Version20250630093000 extends AbstractMigrationChamilo
13
{
14
    public function getDescription(): string
15
    {
16
        return 'Create push_subscription table for browser push notifications.';
17
    }
18
19
    public function up(Schema $schema): void
20
    {
21
        $this->addSql(
22
            "CREATE TABLE push_subscription (
23
                id INT AUTO_INCREMENT NOT NULL,
24
                user_id INT DEFAULT NULL,
25
                endpoint LONGTEXT NOT NULL,
26
                public_key LONGTEXT NOT NULL,
27
                auth_token LONGTEXT NOT NULL,
28
                content_encoding VARCHAR(20) DEFAULT 'aesgcm',
29
                user_agent LONGTEXT DEFAULT NULL,
30
                created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)',
31
                updated_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)',
32
                INDEX idx_push_subscription_user (user_id),
33
                PRIMARY KEY(id)
34
            ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC;"
35
        );
36
37
        $this->addSql(
38
            "ALTER TABLE push_subscription
39
                ADD CONSTRAINT FK_562830F3A76ED395
40
                FOREIGN KEY (user_id)
41
                REFERENCES user (id)
42
                ON DELETE CASCADE;"
43
        );
44
    }
45
46
    public function down(Schema $schema): void
47
    {
48
        $this->addSql("DROP TABLE push_subscription;");
49
    }
50
}
51