Doctrine 1.2 build-all-reload只破坏并构建一个数据库

时间:2012-04-24 15:14:02

标签: doctrine command-line-interface doctrine-1.2

我在项目中设置了两个不同的连接: 第一个用于新项目的数据库,第二个用于获取旧数据的数据库并在新数据库中插入

我的application.ini

; doctrine settings
doctrine.newdsn                = "mysql://user:password@localhost/newdb"
doctrine.olddsn           = "mysql://user:password@localhost/olddb"
doctrine.data_fixtures_path = APPLICATION_PATH "/../doctrine/data/fixtures/data.yml"
doctrine.sql_path           = APPLICATION_PATH "/../doctrine/data/sql"
doctrine.migrations_path    = APPLICATION_PATH "/../doctrine/migrations"
doctrine.yaml_schema_path   = APPLICATION_PATH "/../doctrine/schema"
doctrine.models_path        = APPLICATION_PATH "/models"
doctrine.generate_models_options.generateTableClasses = true
doctrine.generate_models_options.phpDocName = "My Name"
doctrine.generate_models_options.phpDocEmail = "myaddress@email.it"

我的Bootstrap.php

/**
 * initialize doctrine library
 * @return Doctrine_Connection
 */
protected function _initDoctrine()
{
    // retrieve options
    $doctrine = $this->getOption('doctrine');
    // push doctrine model autoloader
    $this->getApplication()->getAutoloader()->pushAutoloader(array('Doctrine_Core', 'autoload'));
    // push doctrine model autoloader
    $this->getApplication()->getAutoloader()->pushAutoloader(array('Doctrine_Core', 'modelsAutoload'));
    // setup doctrine attributes
    $manager = Doctrine_Manager::getInstance();
    $manager->setAttribute(Doctrine_Core::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
    $manager->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
    $manager->setAttribute(Doctrine_Core::ATTR_AUTOLOAD_TABLE_CLASSES, true);
    $manager->setAttribute(Doctrine_Core::ATTR_QUOTE_IDENTIFIER, true);
    $manager->setAttribute(Doctrine_Core::ATTR_USE_NATIVE_ENUM, true);
    // set default encoding
    $manager->setCharset('utf8');
    $manager->setCollate('utf8_unicode_ci');
    // autoloading models
    Doctrine_Core::loadModels(APPLICATION_PATH . '/models');

    // creating connection
    $connOld = Doctrine_Manager::connection($doctrine['olddsn'], 'olddsn');
    Zend_Registry::set('olddsn', $connOld);
    $connNew = Doctrine_Manager::connection($doctrine['newdsn'], 'newdsn');
    Zend_Registry::set('newdsn', $connNew);

    return $connDoctrine;
}

使用这些配置可以轻松地在两个数据库上进行读写。 我的问题是在cli。如果我给命令build-all-reload,doctrine而不是销毁和重新创建新数据库的结构,它还会破坏我不想要的旧数据库?

我该如何解决?

0 个答案:

没有答案