Skip to content

Instantly share code, notes, and snippets.

@hunk
Created January 23, 2010 21:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hunk/284805 to your computer and use it in GitHub Desktop.
Save hunk/284805 to your computer and use it in GitHub Desktop.
<?php
## script migration flutter a Magic fields
## version: 0.1.1
## author: Edgar G (hunk) ing.edgar@gmail.com
## this script is for migrate of flutter 1.1 to Magic Fields 1.3.1
## magicfields.org hunk.com.mx
include('wp-config.php');
include('wp-load.php');
global $wpdb;
// first change all references of the write panel (flutter) for reference of the write panel (magic fields)
$one = $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '_mf_write_panel_id' WHERE meta_key = '_rc_cwp_write_panel_id' ");
echo "changes reference of the write panels in postmeta <br />";
echo "number of changes: ".$one."<br />";
// array with names of tables flutter and Magic Fields
$tables = array();
$tables[$wpdb->prefix."rc_cwp_custom_field_options"] = $wpdb->prefix."mf_custom_field_options";
$tables[$wpdb->prefix."rc_cwp_custom_field_properties"] = $wpdb->prefix."mf_custom_field_properties";
$tables[$wpdb->prefix."rc_cwp_custom_field_types"] = $wpdb->prefix."mf_custom_field_types";
$tables[$wpdb->prefix."rc_cwp_module_groups"] = $wpdb->prefix."mf_module_groups";
$tables[$wpdb->prefix."rc_cwp_panel_category"] = $wpdb->prefix."mf_panel_category";
$tables[$wpdb->prefix."rc_cwp_panel_custom_field"] = $wpdb->prefix."mf_panel_custom_field";
$tables[$wpdb->prefix."rc_cwp_panel_standard_field"] = $wpdb->prefix."mf_panel_standard_field";
$tables[$wpdb->prefix."rc_cwp_post_meta"] = $wpdb->prefix."mf_post_meta";
$tables[$wpdb->prefix."rc_cwp_write_panels"] = $wpdb->prefix."mf_write_panels";
// changes names of table
foreach($tables as $k => $v){
$sql = "RENAME TABLE $k TO $v";
$table = $wpdb->query($sql);
if($table == 0){
echo "table migrate: ".$k." to ".$v." .............<b>correct</b><br />";
}else{
echo "table migrate: ".$k." to ".$v." .............error<br />";
}
}
//for version 1.3
$wpdb->query('ALTER TABLE '.$wpdb->prefix.'mf_panel_custom_field MODIFY display_order INTEGER');
$wpdb->query('ALTER TABLE '.$wpdb->prefix.'mf_panel_custom_field ADD COLUMN help_text text after duplicate');
$wpdb->query('ALTER TABLE '.$wpdb->prefix.'mf_write_panels MODIFY display_order INTEGER');
$wpdb->query('INSERT IGNORE INTO '.$wpdb->prefix.'mf_custom_field_types VALUES (14, "Related Type", NULL, "false", "true", "false")');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment