MOON
Server: Apache
System: Linux res.emeff.ca 3.10.0-962.3.2.lve1.5.24.10.el7.x86_64 #1 SMP Wed Mar 20 07:36:02 EDT 2019 x86_64
User: accemeff (1004)
PHP: 7.0.33
Disabled: NONE
Upload Files
File: /home/accemeff/vendor/craftcms/cms/src/migrations/m150403_183908_migrations_table_changes.php
<?php

namespace craft\migrations;

use craft\db\Migration;
use craft\db\MigrationManager;
use craft\db\Table;
use craft\helpers\MigrationHelper;

/**
 * m150403_183908_migrations_table_changes migration.
 */
class m150403_183908_migrations_table_changes extends Migration
{
    // Public Methods
    // =========================================================================

    /**
     * @inheritdoc
     */
    public function safeUp()
    {
        if (!$this->db->columnExists(Table::MIGRATIONS, 'name')) {
            MigrationHelper::renameColumn(Table::MIGRATIONS, 'version', 'name', $this);
        }

        if (!$this->db->columnExists(Table::MIGRATIONS, 'type')) {
            $values = [
                MigrationManager::TYPE_APP,
                MigrationManager::TYPE_PLUGIN,
                MigrationManager::TYPE_CONTENT,
            ];
            $this->addColumn(Table::MIGRATIONS, 'type', $this->enum('type', $values)->after('pluginId')->notNull()->defaultValue(MigrationManager::TYPE_APP));
            $this->createIndex(null, Table::MIGRATIONS, ['type', 'pluginId']);
        }

        MigrationHelper::dropIndexIfExists(Table::MIGRATIONS, ['name'], true, $this);

        $this->update(Table::MIGRATIONS, ['type' => 'plugin'], ['not', ['pluginId' => null]]);
    }

    /**
     * @inheritdoc
     */
    public function safeDown()
    {
        echo "m150403_183908_migrations_table_changes cannot be reverted.\n";

        return false;
    }
}