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/m180810_214439_soft_delete_elements.php
<?php

namespace craft\migrations;

use craft\db\Migration;
use craft\db\Table;

/**
 * m180810_214439_soft_delete_elements migration.
 */
class m180810_214439_soft_delete_elements extends Migration
{
    /**
     * @inheritdoc
     */
    public function safeUp()
    {
        // Add the dateDeleted column
        $this->addColumn(Table::ELEMENTS, 'dateDeleted', $this->dateTime()->null()->after('dateUpdated'));
        $this->createIndex(null, Table::ELEMENTS, ['dateDeleted'], false);

        // Give categories and Structure section entries a way to keep track of their parent IDs
        // in case they are soft-deleted and need to be restored
        $this->addColumn(Table::CATEGORIES, 'parentId', $this->integer()->after('groupId'));
        $this->addColumn(Table::ENTRIES, 'parentId', $this->integer()->after('sectionId'));
        $this->addForeignKey(null, Table::CATEGORIES, ['parentId'], Table::CATEGORIES, ['id'], 'SET NULL', null);
        $this->addForeignKey(null, Table::ENTRIES, ['parentId'], Table::ENTRIES, ['id'], 'SET NULL', null);
    }

    /**
     * @inheritdoc
     */
    public function safeDown()
    {
        echo "m180810_214439_soft_delete_elements cannot be reverted.\n";
        return false;
    }
}