Code snippets for symfony 1.x

Navigation

Refine Tags

Snippets tagged "migration"

Get the actual version of Doctrine Migration

$migration_path = sfConfig::get('sf_lib_dir').DIRECTORY_SEPARATOR.'migration'.DIRECTORY_SEPARATOR.'doctrine';
    $doctrine_migration = new Doctrine_Migration($migration_path);
 
    $this->migration_current_version = $doctrine_migration->getCurrentVersion();
    $this->migration_latest_version  = $doctrine_migration->getLatestVersion();
 

Allow you to check if the database actually need to be migrated.

by Damien ALEXANDRE on 2010-11-19, tagged doctrine  migration  migrationversion 

Use databases.yml in Ruckusing Migrations

Replace (or link) Ruckusing's database.inc.php with this code. You'll be able to use symfony's environment names in Ruckusing commands.

Example: php lib/vendor/ruckusing/main.php db:migrate ENV=dev

<?php
$configFile = dirname(__FILE__)."/../../../../config/databases.yml";
include(dirname(__FILE__)."/../../symfony/lib/yaml/sfYaml.class.php");
$connections = sfYaml::Load($configFile);
 
foreach($connections as $con => $val)
{
  if($con == 'all') continue;
  $connection_name = $con;
  $con = array();
  $params = array_pop($val);
  $params = $params['param'];
 
  preg_match("/^(.*)\:/", $params['dsn'], $match);
  $con['type'] = $match[1];
 
  preg_match("/dbname=(.*);/", $params['dsn'], $match);
  $con['database'] = $match[1];
 
  preg_match("/host=(.*);?/", $params['dsn'], $match);
  $con['host'] = $match[1];
 
  if(preg_match("/port=(.*);?/", $params['dsn'], $match))
  {
    $con['port'] = $match[1];
  }
  elseif($con['type'] == 'mysql')
  {
    $con['port'] = 3306;
  }
 
  $con['user'] = $params['username'];
  $con['password'] = $params['password'];
 
  $ruckusing_db_config[$connection_name] = $con;
}
 
// dev and development means the same thing in the two config files
$ruckusing_db_config['development'] = $ruckusing_db_config['dev'];
?>
 
by karoly sz on 2009-10-18, tagged migration  ruckusing