View file database/upgrades/20200629222858_replace_chars_in_ignoring.php

File size: 1.83Kb
<?php

use Phinx\Migration\AbstractMigration;

class ReplaceCharsInIgnoring extends AbstractMigration
{
    /**
     * Migrate Up.
     */
    public function up(): void
    {
        $this->execute("UPDATE ignoring SET text = replace(`text`, '&amp;', '&')");
        $this->execute("UPDATE ignoring SET text = replace(`text`, '&quot;', '\"')");
        $this->execute("UPDATE ignoring SET text = replace(`text`, '&#039;', \"'\")");
        $this->execute("UPDATE ignoring SET text = replace(`text`, '&#39;', \"'\")");
        $this->execute("UPDATE ignoring SET text = replace(`text`, '&#36;', '$')");
        $this->execute("UPDATE ignoring SET text = replace(`text`, '&#92;', '\\\')");
        $this->execute("UPDATE ignoring SET text = replace(`text`, '&#124;', '|')");
        $this->execute("UPDATE ignoring SET text = replace(`text`, '&#94;', '^')");
        $this->execute("UPDATE ignoring SET text = replace(`text`, '&#96;', '`')");
        $this->execute("UPDATE ignoring SET text = replace(`text`, '&#37;', '%')");
        $this->execute("UPDATE ignoring SET text = replace(`text`, '&#58;', ':')");
        $this->execute("UPDATE ignoring SET text = replace(`text`, '&#64;', '@')");
        $this->execute("UPDATE ignoring SET text = replace(`text`, '&lt;', '<')");
        $this->execute("UPDATE ignoring SET text = replace(`text`, '&gt;', '>')");
    }

    /**
     * Migrate Down.
     */
    public function down(): void
    {
        $this->execute("UPDATE ignoring SET text = replace(`text`, '&', '&amp;')");
        $this->execute("UPDATE ignoring SET text = replace(`text`, '\"', '&quot;')");
        $this->execute("UPDATE ignoring SET text = replace(`text`, \"'\", '&#039;')");
        $this->execute("UPDATE ignoring SET text = replace(`text`, '<', '&lt;')");
        $this->execute("UPDATE ignoring SET text = replace(`text`, '>', '&gt;')");
    }
}