<?php

use Schema\Wrapper as Wrapper;
use App\Core\Sanity\MigratorController as Migrator;

//https://book.cakephp.org/phinx/0/en/migrations.html#valid-column-types
function core_cache_upgrade($pluginversion) {
    if ($pluginversion < "0.0.1") {
        $table = Wrapper::get_table("core_caches");
        $table->addColumn("key", "string", Array("null" => false));
        $table->addColumn("type", "string", Array("null" => false));
        $table->addColumn("format", "string", Array("null" => false));
        $table->addColumn("value", "text", Array("null" => true));

        $table->addTimestamps();
        $table->create();

        Migrator::getInstance()->update_plugin_version("core_cache", "1.0.0");
        return;
    }

}

function core_cache_rollback($pluginversion) {
    if($pluginversion > "0.0.1"){
        $table = Wrapper::get_table("core_caches");
        $table->drop();
        return;
    }
}