zend-blog-3-backend

Форк
0
/
Version20230616153217.php 
39 строк · 1.9 Кб
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Application\Migrations;
6

7
use Doctrine\DBAL\Schema\Schema;
8
use Doctrine\Migrations\AbstractMigration;
9

10
/**
11
 * Auto-generated Migration: Please modify to your needs!
12
 */
13
final class Version20230616153217 extends AbstractMigration
14
{
15
    public function up(Schema $schema): void
16
    {
17
        // this up() migration is auto-generated, please modify it to your needs
18
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
19

20
        $this->addSql('DROP INDEX UNIQ_5F9E962AE46417AB ON comments');
21
        $this->addSql('ALTER TABLE comments ADD ip_long INT UNSIGNED DEFAULT NULL AFTER ip_addr, DROP disqus_id');
22
        $this->addSql('UPDATE comments AS c, geo_location AS g SET c.ip_long = g.ip_long WHERE c.ip_addr IS NOT NULL AND g.ip_long = INET_ATON(c.ip_addr)');
23
        $this->addSql('CREATE INDEX IDX_5F9E962A28F0F5E7 ON comments (ip_long)');
24
        $this->addSql('ALTER TABLE geo_location ADD count_of_check SMALLINT UNSIGNED DEFAULT 0 NOT NULL');
25
        $this->addSql('ALTER TABLE comments ADD CONSTRAINT FK_5F9E962A28F0F5E7 FOREIGN KEY (ip_long) REFERENCES geo_location (ip_long) ON DELETE SET NULL');
26
    }
27

28
    public function down(Schema $schema): void
29
    {
30
        // this down() migration is auto-generated, please modify it to your needs
31
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
32

33
        $this->addSql('ALTER TABLE comments DROP FOREIGN KEY FK_5F9E962A28F0F5E7');
34
        $this->addSql('ALTER TABLE geo_location DROP count_of_check');
35
        $this->addSql('DROP INDEX IDX_5F9E962A28F0F5E7 ON comments');
36
        $this->addSql('ALTER TABLE comments ADD disqus_id BIGINT DEFAULT NULL, DROP ip_long');
37
        $this->addSql('CREATE UNIQUE INDEX UNIQ_5F9E962AE46417AB ON comments (disqus_id)');
38
    }
39
}
40

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.