Added stub for database query profiling.
[fa-stable.git] / sql / alter2.4.php
index 0a2584d346a77ebd6f7dc3294959224d081e7f53..c51f19962c7a347ee82d4abbafa951006674b8be 100644 (file)
@@ -32,58 +32,38 @@ class fa2_4 {
                if (get_company_pref('grn_clearing_act') === null) { // available form 2.3.1, can be not defined on pre-2.4 installations
                        set_company_pref('grn_clearing_act', 'glsetup.purchase', 'varchar', 15, 0);
                }
-               if (get_company_pref('default_receival_required') === null) { // new in 2.4 installations
-                       set_company_pref('default_receival_required', 'glsetup.purchase', 'smallint', 6, 10);
-               }
                if (get_company_pref('default_quote_valid_days') === null) { // new in 2.3.23 installations
                        set_company_pref('default_quote_valid_days', 'glsetup.sales', 'smallint', 6, 30);
                }
-               if (get_company_pref('no_zero_lines_amount') === null) { // new in 2.4 installations
-                       set_company_pref('no_zero_lines_amount', 'glsetup.sales', 'tinyint', 1, '1');
-                       refresh_sys_prefs();
-               }
-               if (get_company_pref('show_po_item_codes') === null) { // new in 2.4 installations
-                       set_company_pref('show_po_item_codes', 'glsetup.purchase', 'tinyint', 1, '0');
-                       refresh_sys_prefs();
-               }
-               if (get_company_pref('accounts_alpha') === null) { // new in 2.4 installations
-                       set_company_pref('accounts_alpha', 'glsetup.general', 'tinyint', 1, '0');
-                       refresh_sys_prefs();
-               }
-               if (get_company_pref('loc_notification') === null) { // new in 2.4 installations
-                       set_company_pref('loc_notification', 'glsetup.inventory', 'tinyint', 1, '0');
-                       refresh_sys_prefs();
-               }
-               if (get_company_pref('print_invoice_no') === null) { // new in 2.4 installations
-                       set_company_pref('print_invoice_no', 'glsetup.sales', 'tinyint', 1, '0');
-                       refresh_sys_prefs();
-               }
-               if (get_company_pref('allow_negative_prices') === null) { // new in 2.4 installations
-                       set_company_pref('allow_negative_prices', 'glsetup.inventory', 'tinyint', 1, '1');
-                       refresh_sys_prefs();
-               }
-               if (get_company_pref('print_item_images_on_quote') === null) { // new in 2.4 installations
-                       set_company_pref('print_item_images_on_quote', 'glsetup.inventory', 'tinyint', 1, '0');
-                       refresh_sys_prefs();
-               }
                if (get_company_pref('bcc_email') === null) { // available from 2.3.14, can be not defined on pre-2.4 installations
                        set_company_pref('bcc_email', 'setup.company', 'varchar', 100, '');
-                       refresh_sys_prefs();
                }
                if (get_company_pref('alternative_tax_include_on_docs') === null) { // available from 2.3.14, can be not defined on pre-2.4 installations
                        set_company_pref('alternative_tax_include_on_docs', 'setup.company', 'tinyint', 1, '0');
-                       refresh_sys_prefs();
                }
                if (get_company_pref('suppress_tax_rates') === null) { // available from 2.3.14, can be not defined on pre-2.4 installations
                        set_company_pref('suppress_tax_rates', 'setup.company', 'tinyint', 1, '0');
-                       refresh_sys_prefs();
                }
 
-$result = $this->update_workorders()  && $this->update_grn_rates() && $this->switch_database_to_utf($pref);
+               $result = $this->update_workorders()  && $this->update_grn_rates() && $this->switch_database_to_utf($pref);
 
                if ($result)
                        $result = $this->do_cleanup();
 
+               //remove obsolete and temporary columns.
+               // this have to be done here as db_import rearranges alter query order
+               $dropcol = array(
+                               'cust_branch' => array('contact_name', 'disable_trans'),
+               );
+
+               foreach($dropcol as $table => $columns)
+                       foreach($columns as $col) {
+                               if (db_query("ALTER TABLE `".TB_PREF."{$table}` DROP `$col`")==false) {
+                                       display_error("Cannot drop {$table}.{$col} column:<br>".db_error_msg($db));
+                                       return false;
+                               }
+                       }
+
                return  update_company_prefs(array('version_id'=>$db_version));
        }
        //
@@ -166,7 +146,7 @@ $result = $this->update_workorders()  && $this->update_grn_rates() && $this->swi
                 // site default encoding is presumed as encoding for all databases!
                $lang = array_search_value($dflt_lang, $installed_languages, 'code');
                $new_encoding = get_mysql_encoding_name(strtoupper($lang['encoding']));
-       //      get_usec();
+
                if ($test)
                        error_log('Switching database to utf8 encoding from '.$old_encoding);
                $collation = get_mysql_collation();
@@ -174,7 +154,6 @@ $result = $this->update_workorders()  && $this->update_grn_rates() && $this->swi
                $tresult = db_query($tsql, "Cannot select all tables with prefix '$pref'");
                while($tbl = db_fetch($tresult)) {
                        $table = $tbl[0];
-               // if ($table != '1_chart_master') continue; _vd($table); get_usec(); // fast debug on single table
 
                        db_query("ALTER TABLE `$table` CONVERT TO CHARACTER SET $old_encoding"); // convert encoding on utf-8 tables