Return to Snippet

Revision: 18818
at October 9, 2009 09:08 by berkes


Initial Code
/**
 * Make these queries with mysqldump -uusernam -p database_name -t blocks -c --compact --skip-extended-insert | sort | uniq  > sitese/all/modules/projectname_meta/blocks.sql 
 **/
function projectname_meta_update_5002() {
  $ret = array();
  
  $files = array(
    'blocks' => 'blocks.sql',
  );
  
  foreach($files as $table => $name) {
    $lines = file(drupal_get_path('module', 'ogt_meta') .'/'. $name);
    if (count($lines) > 0) {
      $table = db_escape_string($table);
      $ret[] = update_sql('TRUNCATE {'. $table .'}');
   
      foreach ($lines as $line_num => $line) {
        $ret[] = update_sql($line);
      }
    }
  }
  
  return $ret;
}

Initial URL
http://webschuur.com

Initial Description
Takes a .sql file and runs trough that, each line as an update_sql. 
Very usefull to track and migrate your blocks/views/cck etc changes.

Initial Title
Track block/views/cck etc changes in RCS and migrate with Drupal updates.

Initial Tags
database, drupal

Initial Language
PHP