View file database/upgrades/20170925113133_delete_emails_and_nickname_in_setting.php

File size: 801B
<?php

use Phinx\Migration\AbstractMigration;

class DeleteEmailsAndNicknameInSetting extends AbstractMigration
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $setting = $this->fetchRow("SELECT value FROM setting WHERE name = 'nickname'");

        $this->execute("UPDATE users SET level='boss' WHERE login = '".$setting['value']."' LIMIT 1;");
        $this->execute("DELETE FROM setting WHERE name='emails' LIMIT 1;");
        $this->execute("DELETE FROM setting WHERE name='nickname' LIMIT 1;");
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $this->execute("INSERT INTO setting (name, value) VALUES ('emails', '[email protected]');");
        $this->execute("INSERT INTO setting (name, value) VALUES ('nickname', 'admin');");
    }
}