X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sql%2Falter2.1.php;h=1dade60291f2aba2d255e3e8b4cf55e605d33ba5;hb=a31195793c023906ab5da62f06ab84aefed445c3;hp=869186ac0cd4d671cea0c3dd13592474870124c7;hpb=0b63d898491b6577a5a5bf90e771dca0dcbbcf1f;p=fa-stable.git diff --git a/sql/alter2.1.php b/sql/alter2.1.php index 869186ac..1dade602 100644 --- a/sql/alter2.1.php +++ b/sql/alter2.1.php @@ -9,19 +9,20 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License here . ***********************************************************************/ -class fa2_1 { +class fa2_1 extends fa_patch { + var $previous = ''; // applicable database version var $version = '2.1'; // version installed var $description; var $sql = 'alter2.1.sql'; - function fa2_1() { + function __construct() { $this->description = _('Upgrade from version 2.0 to 2.1'); } // // Install procedure. All additional changes // not included in sql file should go here. // - function install($company, $force) + function install($company, $force=false) { global $db; @@ -69,7 +70,7 @@ class fa2_1 { } // remove obsolete bank_trans_types table // (DROP queries are skipped during non-forced upgrade) - $sql = "DROP TABLE IF EXISTS `0_bank_trans_types`"; + $sql = "DROP TABLE IF EXISTS `".TB_PREF."bank_trans_types`"; db_query($sql); // // Move all debtor and supplier trans tax details to new table @@ -128,13 +129,16 @@ class fa2_1 { return true; } + // // Checking before install // - function pre_check($pref) + function prepare() { // We cannot perform successfull upgrade on system where the - // trans tax details tables was deleted during previous try. + // trans tax details tables was deleted during previous try. + $pref = $this->companies[$company]['tbpref']; + if (check_table($pref, 'debtor_trans_tax_details') || check_table($pref, 'supp_invoice_tax_items')) { display_error(_("Seems that system upgrade to version 2.1 has @@ -143,24 +147,10 @@ class fa2_1 { database restore from last backup file first.")); return false; - } + } return true; // true when ok, fail otherwise } - // - // Test if patch was applied before. - // - function installed($pref) { - $n = 4; // number of features to be installed - if (!check_table($pref, 'item_codes')) $n--; -// if (!check_table($pref, 'company', 'foreign_codes')) $n--; - if (!check_table($pref, 'suppliers', 'credit_limit')) $n--; - if (!check_table($pref, 'bank_trans', 'reconciled', - array('Type'=>'date'))) $n--; - if (!check_table($pref, 'trans_tax_details')) $n--; - return $n == 0 ? true : 5 - $n; - } }; $install = new fa2_1; -?> \ No newline at end of file