Created
November 6, 2009 01:08
-
-
Save hunk/227581 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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.2 | |
## 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.2 | |
$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'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment