From: Elena Mamontova Date: Thu, 7 Jul 2016 14:20:59 +0000 (+0300) Subject: Ticket 37. if (schemaVersion > 1) checking added in the SaveTariff() X-Git-Tag: 2.409~149 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/c4731aeaa82ed94af67f4697abf58221a2f43adf?ds=sidebyside Ticket 37. if (schemaVersion > 1) checking added in the SaveTariff() function. --- diff --git a/projects/stargazer/plugins/store/firebird/firebird_store_tariffs.cpp b/projects/stargazer/plugins/store/firebird/firebird_store_tariffs.cpp index a7b719ed..f2d70879 100644 --- a/projects/stargazer/plugins/store/firebird/firebird_store_tariffs.cpp +++ b/projects/stargazer/plugins/store/firebird/firebird_store_tariffs.cpp @@ -150,7 +150,7 @@ try int32_t id; st->Get(1, id); st->Close(); - if (schemaVersion > 0) + if (schemaVersion == 1) { st->Prepare("update tb_tariffs set \ fee = ?, \ @@ -168,17 +168,38 @@ try } else { - st->Prepare("update tb_tariffs set \ - fee = ?, \ - free = ?, \ - passive_cost = ?, \ - traff_type = ? \ - where pk_tariff = ?"); - st->Set(1, td.tariffConf.fee); - st->Set(2, td.tariffConf.free); - st->Set(3, td.tariffConf.passiveCost); - st->Set(4, td.tariffConf.traffType); - st->Set(5, id); + if (schemaVersion > 1) + { + st->Prepare("update tb_tariffs set \ + fee = ?, \ + free = ?, \ + passive_cost = ?, \ + traff_type = ?, \ + period = ? \ + change_policy = ? \ + where pk_tariff = ?"); + st->Set(1, td.tariffConf.fee); + st->Set(2, td.tariffConf.free); + st->Set(3, td.tariffConf.passiveCost); + st->Set(4, td.tariffConf.traffType); + st->Set(5, TARIFF::PeriodToString(td.tariffConf.period)); + st->Set(6, TARIFF::ChangePolicyToString(td.tariffConf.changePolicy)); + st->Set(7, id); + } + else + { + st->Prepare("update tb_tariffs set \ + fee = ?, \ + free = ?, \ + passive_cost = ?, \ + traff_type = ? \ + where pk_tariff = ?"); + st->Set(1, td.tariffConf.fee); + st->Set(2, td.tariffConf.free); + st->Set(3, td.tariffConf.passiveCost); + st->Set(4, td.tariffConf.traffType); + st->Set(5, id); + } } st->Execute(); st->Close();