i have two database called "migrate_new" and "migrate_old" and both have one table called "cms_pages".
i want to compare "migrate_old" db "cms_pages" with the "migrate_new" "cms_pages" table structure if "migrate_new" database "cms_pages" does not have "field" then alter table automatically.
below is my code to compare "migrate_old" "cms_pages" fields not in "migrate_new" "cms_pages" now i want to add this fields on table. i want to continue the process in place of exit.
**> any one can have idea to add fields automatically so no need to stop migration task?
i am not able to get field details like type , key , etc. how i know alter table with use modify or add fields. i short i want to set structure with out loss of any data automatically. thanks in advance..
**
$this->load->database();
$admin_db = $this->load->database('ADMINDB', TRUE);
$query = $this->db->get('cms_page');
$result = $query->result();
$fields_old = $this->db->list_fields('cms_page');
// $fields_new = $admin_db->list_fields('cms_page');
$flag = false;
foreach ($fields_old as $field){
if (!$admin_db->field_exists($field, 'cms_page'))
{
echo $field.'=> is not exists in new table please contact to developer for that <br>';
$flag = true;
}
}
if($flag){
exit;
}