Ejemplo n.º 1
0
 /**
  * Generates a baseline
  *
  * This method is called outside the
  * overall versioning process
  *
  * @return void
  * */
 public function generateBaseline()
 {
     // get the new version number
     $baseline_version = $this->latest_db_version == '0.0.0' ? '1.0.0' : $this->incrementVersionNumber($this->latest_db_version);
     // generate baseline path
     $baseline_absolute_path = CodePax_DbVersioning_Files_Manager::getPathToBaselines() . DIRECTORY_SEPARATOR . $baseline_version . CodePax_DbVersioning_Files_Manager::SQL_FILE_EXTENSION;
     // factory the SQL engine object and generate baseline file
     $this->sql_engine->generateBaseline($baseline_absolute_path);
     // register baseline to DB
     $this->db_versions_model->addVersion($baseline_version, CodePax_DbVersions::TYPE_BASELINE);
     // commit the new baseline and versioning DB
     $svn_wrapper = new CodePax_Scm_Svn(SCM_USER, SCM_PASS, REPO_URL, PROJECT_DIR);
     $svn_wrapper->addAndCommit("SVN GUI generated baseline at version {$baseline_version}", DB_VERSIONING_DIR);
 }
Ejemplo n.º 2
0
}
//--- show HOOKS section
if (defined('USE_HOOKS')) {
    $view->use_hooks = USE_HOOKS;
    $hooks_hanlder = new CodePax_Hooks_Handler();
    $hooks = $hooks_hanlder->getList();
    $view->hooks = array_keys($hooks);
}
//--- show Db versioning section
if (defined('USE_DB_VERSIONING') && USE_DB_VERSIONING === true) {
    $view->use_db_versioning = true;
    try {
        // get current DB version
        $db_versions_model = CodePax_DbVersions::factory();
        if (in_array(APPLICATION_ENVIRONMENT, array('dev', 'prod'))) {
            $latest_baseline_file = CodePax_DbVersioning_Files_Manager::getLatestBaselineVersion();
            if (!$db_versions_model->checkIsVersionRegistred($latest_baseline_file, CodePax_DbVersions::TYPE_BASELINE)) {
                $db_versions_model->addVersion($latest_baseline_file, CodePax_DbVersions::TYPE_BASELINE);
            }
        }
        $latest_structure_version = $db_versions_model->getLatestVersion(CodePax_DbVersions::TYPE_CHANGE_SCRIPT);
        $latest_data_version = $db_versions_model->getLatestVersion(CodePax_DbVersions::TYPE_DATA_CHANGE_SCRIPT);
        $view->database_name = DB_NAME;
        $view->database_structure_version = $latest_structure_version[CodePax_DbVersions::VERSION_ATTRIBUTE];
        $view->database_structure_last_update = $latest_structure_version[CodePax_DbVersions::DATE_ADDED_ATTRIBUTE];
        $view->database_data_version = $latest_data_version[CodePax_DbVersions::VERSION_ATTRIBUTE];
        $view->database_data_last_update = !empty($latest_data_version[CodePax_DbVersions::DATE_ADDED_ATTRIBUTE]) ? $latest_data_version[CodePax_DbVersions::DATE_ADDED_ATTRIBUTE] : 'n/a';
        // get change scripts to run
        $db_versioning_handler = CodePax_DbVersioning_Environments_Factory::factory(APPLICATION_ENVIRONMENT);
        $change_scripts = $db_versioning_handler->getChangeScripts();
        $data_change_scripts = $db_versioning_handler->getDataChangeScripts();
Ejemplo n.º 3
0
 /**
  * Set the latest database version to an internal
  * class property
  *
  * On DEV, the latest version will be considered the
  * latest baseline found on the file system
  *
  * Override @see DbVersioning_Environments_Abstract::setLatestDbVersion
  *
  * @return void
  * */
 protected function setLatestDbVersion()
 {
     $this->latest_db_version = CodePax_DbVersioning_Files_Manager::getLatestBaselineVersion();
 }
Ejemplo n.º 4
0
 /**
  * Returns the data change scripts list from
  * the filesystem
  *
  * This method may be called outside the
  * overall versioning process to simply
  * return a list of change scripts starting
  * with the @see $latest_db_version
  *
  * The returned array looks like this:
  * Array (
  * 	[1.1.2] => /var/www/site/dbv/data_change_scripts/1.1.2.sql
  * 	[1.1.3] => /var/www/site/dbv/data_change_scripts/1.1.3.sql
  * 	)
  *
  * @return array
  * */
 public final function getDataChangeScripts()
 {
     return CodePax_DbVersioning_Files_Manager::getDataChangeScriptsByVersion($this->latest_data_db_version);
 }
Ejemplo n.º 5
0
 /**
  * Returns the data change scripts list from
  * the filesystem
  *
  * This method may be called outside the
  * overall versioning process to simply
  * return a list of change scripts starting
  * with the @see $latest_db_version
  *
  * The returned array looks like this:
  * Array (
  * 	[1.1.2] => /var/www/site/dbv/data_change_scripts/1.1.2.sql
  * 	[1.1.3] => /var/www/site/dbv/data_change_scripts/1.1.3.sql
  * 	)
  *
  * @return array
  * */
 public final function getDataChangeScripts()
 {
     $filesManager = new CodePax_DbVersioning_Files_Manager($this->configuration);
     return $filesManager->getDataChangeScriptsByVersion($this->latest_data_db_version);
 }