Posted By

berkes on 10/09/09


Tagged

database configuration drupal migration fixture


Versions (?)

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


 / Published in: PHP
 

URL: http://webschuur.com

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.

  1. /**
  2.  * 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
  3.  **/
  4. function projectname_meta_update_5002() {
  5. $ret = array();
  6.  
  7. $files = array(
  8. 'blocks' => 'blocks.sql',
  9. );
  10.  
  11. foreach($files as $table => $name) {
  12. $lines = file(drupal_get_path('module', 'ogt_meta') .'/'. $name);
  13. if (count($lines) > 0) {
  14. $table = db_escape_string($table);
  15. $ret[] = update_sql('TRUNCATE {'. $table .'}');
  16.  
  17. foreach ($lines as $line_num => $line) {
  18. $ret[] = update_sql($line);
  19. }
  20. }
  21. }
  22.  
  23. return $ret;
  24. }

Report this snippet  

You need to login to post a comment.