<?php
class UpgradeScript extends Upgrade{
    
    var $noticeMsg = array();
    
    //自动校验数据库 2013-10-25 by Ardon
    function upgrade_checkDB(){
        //校验数据库
        $schema = &$this->system->loadModel('utility/schemas');
        $ret = array();
        $db = &$this->system->database();
        $dbtables = $schema->get_system_schemas();
        foreach($dbtables as $tbname=>$struct){
            if($diff = $schema->diff($tbname,$struct)){
                //$ret[$db->prefix.$tbname] = $diff;
                foreach($diff as $sql){
                    if( strpos($sql,'op_sessions')){
                        $db->exec('truncate table sdb_op_sessions');
                    }
                    $db->exec($sql);
                }
            }
        }
        $this->clear_enterprise();
        return 'finish';
    }
    
    
    //清除激活信息，重新激活网店 2013-10-25 by Ardon
    function clear_enterprise(){
        $certMdl = $this->system->loadModel('service/certificate');
        
        $certMdl->delEnterprise();
        return 'finish';
    }
}

?>