<?php

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

function common_files_upgrade($pluginversion) {
    if ($pluginversion < "0.0.1") {
        $table = Wrapper::get_table("common_filess");
        $table->addColumn("name", "string", Array("null" => false));
        $table->addColumn("time", "timestamp", Array("null" => true, "default"=>null));
        $table->addColumn("areaid", "integer", Array("null" => false));
        $table->addTimestamps();
        $table->addSoftDelete();
        $table->create();

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

    //if ($pluginversion < "0.0.2") {
        //$table = Wrapper::get_table("common_filess");
        //Migrator::getInstance()->update_plugin_version("common_files", "1.0.1");
        //return;
    //}
}

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