gnucash unstable: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Thu Nov 23 15:16:45 EST 2017


Updated	 via  https://github.com/Gnucash/gnucash/commit/9c4635e3 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/937f8c50 (commit)
	from  https://github.com/Gnucash/gnucash/commit/2cbfc5bb (commit)



commit 9c4635e3930f6026080cf18ea7ca92133733c944
Author: John Ralls <jralls at ceridwen.us>
Date:   Thu Nov 23 11:41:09 2017 -0800

    Bug 784623 - GNUCash does not work with sql backend.
    
    Wherin the problem is that MySQL's TIMESTAMP has a date range of
    1970-01-01 00:00:01 to 2038-01-19 03:14:07 and is unable to handle
    time_t of 0. MySQL's TIMESTAMP also assumes that input is in the server's
    timezone and adjusts it to UTC. GnuCash has already done that conversion.

diff --git a/libgnucash/backend/dbi/gnc-dbiproviderimpl.hpp b/libgnucash/backend/dbi/gnc-dbiproviderimpl.hpp
index 47795f9..32f3ec6 100644
--- a/libgnucash/backend/dbi/gnc-dbiproviderimpl.hpp
+++ b/libgnucash/backend/dbi/gnc-dbiproviderimpl.hpp
@@ -130,7 +130,7 @@ GncDbiProviderImpl<DbType::DBI_MYSQL>::append_col_def (std::string& ddl,
     }
     else if (info.m_type == BCT_DATETIME)
     {
-        type_name = "TIMESTAMP NULL DEFAULT 0";
+        type_name = "DATETIME NULL DEFAULT '1970-01-01 00:00:00'";
     }
     else
     {
diff --git a/libgnucash/backend/sql/gnc-entry-sql.cpp b/libgnucash/backend/sql/gnc-entry-sql.cpp
index c8be0d9..9beb95b 100644
--- a/libgnucash/backend/sql/gnc-entry-sql.cpp
+++ b/libgnucash/backend/sql/gnc-entry-sql.cpp
@@ -57,7 +57,7 @@ extern "C"
 static QofLogModule log_module = G_LOG_DOMAIN;
 
 #define TABLE_NAME "entries"
-#define TABLE_VERSION 3
+#define TABLE_VERSION 4
 #define MAX_DESCRIPTION_LEN 2048
 #define MAX_ACTION_LEN 2048
 #define MAX_NOTES_LEN 2048
@@ -226,6 +226,7 @@ GncSqlEntryBackend::create_tables (GncSqlBackend* sql_be)
         /* Upgrade:
             1->2: 64 bit int handling
             2->3: "entered" -> "date_entered", and it can be NULL
+            3->4: Use DATETIME instead of TIMESTAMP in MySQL
         */
         sql_be->upgrade_table(TABLE_NAME, col_table);
         sql_be->set_table_version (TABLE_NAME, TABLE_VERSION);
diff --git a/libgnucash/backend/sql/gnc-invoice-sql.cpp b/libgnucash/backend/sql/gnc-invoice-sql.cpp
index 5cfffad..769aa2d 100644
--- a/libgnucash/backend/sql/gnc-invoice-sql.cpp
+++ b/libgnucash/backend/sql/gnc-invoice-sql.cpp
@@ -56,7 +56,7 @@ extern "C"
 static QofLogModule log_module = G_LOG_DOMAIN;
 
 #define TABLE_NAME "invoices"
-#define TABLE_VERSION 3
+#define TABLE_VERSION 4
 
 #define MAX_ID_LEN 2048
 #define MAX_NOTES_LEN 2048
@@ -164,6 +164,7 @@ GncSqlInvoiceBackend::create_tables (GncSqlBackend* sql_be)
         /* Upgrade:
              1->2: 64 bit int handling
              2->3: invoice open date can be NULL
+             3->4: Use DATETIME instead of TIMESTAMP in MySQL
         */
         sql_be->upgrade_table(TABLE_NAME, col_table);
         sql_be->set_table_version (TABLE_NAME, TABLE_VERSION);
diff --git a/libgnucash/backend/sql/gnc-price-sql.cpp b/libgnucash/backend/sql/gnc-price-sql.cpp
index eaf99eb..f2cc188 100644
--- a/libgnucash/backend/sql/gnc-price-sql.cpp
+++ b/libgnucash/backend/sql/gnc-price-sql.cpp
@@ -51,7 +51,7 @@ extern "C"
 static QofLogModule log_module = G_LOG_DOMAIN;
 
 #define TABLE_NAME "prices"
-#define TABLE_VERSION 2
+#define TABLE_VERSION 3
 
 #define PRICE_MAX_SOURCE_LEN 2048
 #define PRICE_MAX_TYPE_LEN 2048
@@ -148,7 +148,10 @@ GncSqlPriceBackend::create_tables (GncSqlBackend* sql_be)
     }
     else if (version < m_version)
     {
-        /* Upgrade 64 bit int handling */
+        /*
+          1->2: Upgrade 64 bit int handling
+          2->3: Use DATETIME instead of TIMESTAMP in MySQL
+        */
         sql_be->upgrade_table(TABLE_NAME, col_table);
         sql_be->set_table_version (TABLE_NAME, TABLE_VERSION);
 
diff --git a/libgnucash/backend/sql/gnc-slots-sql.cpp b/libgnucash/backend/sql/gnc-slots-sql.cpp
index 7cd80fd..8b35b27 100644
--- a/libgnucash/backend/sql/gnc-slots-sql.cpp
+++ b/libgnucash/backend/sql/gnc-slots-sql.cpp
@@ -54,7 +54,7 @@ extern "C"
 static QofLogModule log_module = G_LOG_DOMAIN;
 
 #define TABLE_NAME "slots"
-#define TABLE_VERSION 3
+#define TABLE_VERSION 4
 
 typedef enum
 {
@@ -958,11 +958,12 @@ GncSqlSlotsBackend::create_tables (GncSqlBackend* sql_be)
             PERR ("Unable to create index\n");
         }
     }
-    else if (version < TABLE_VERSION)
+    else if (version < m_version)
     {
         /* Upgrade:
             1->2: 64-bit int values to proper definition, add index
             2->3: Add gdate field
+            3->4: Use DATETIME instead of TIMESTAMP in MySQL
         */
         if (version == 1)
         {
@@ -982,7 +983,7 @@ GncSqlSlotsBackend::create_tables (GncSqlBackend* sql_be)
                 PERR ("Unable to add gdate column\n");
             }
         }
-        else if (version < m_version)
+        else
         {
             sql_be->upgrade_table(TABLE_NAME, col_table);
         }
diff --git a/libgnucash/backend/sql/gnc-transaction-sql.cpp b/libgnucash/backend/sql/gnc-transaction-sql.cpp
index e3ff00f..266d356 100644
--- a/libgnucash/backend/sql/gnc-transaction-sql.cpp
+++ b/libgnucash/backend/sql/gnc-transaction-sql.cpp
@@ -69,7 +69,7 @@ extern "C"
 static QofLogModule log_module = G_LOG_DOMAIN;
 
 #define TRANSACTION_TABLE "transactions"
-#define TX_TABLE_VERSION 3
+#define TX_TABLE_VERSION 4
 #define SPLIT_TABLE "splits"
 #define SPLIT_TABLE_VERSION 4
 
@@ -481,6 +481,7 @@ GncSqlTransBackend::create_tables (GncSqlBackend* sql_be)
         /* Upgrade:
             1->2: 64 bit int handling
             2->3: allow dates to be NULL
+            3->4: Use DATETIME instead of TIMESTAMP in MySQL
         */
         sql_be->upgrade_table(m_table_name.c_str(), tx_col_table);
         sql_be->set_table_version (m_table_name.c_str(), m_version);

commit 937f8c508301a26ede211ee4ed06ad7a91bd2198
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Nov 21 18:12:30 2017 -0800

    Set GncSqlObjectBackend::m_version to the appropriate TABLE_VERSION.
    
    For each subclass, getting rid of GNC_SQL_OBJECT_BACKEND_VERSION which
    was a bit misguided.
    
    Also remove the bogus test the skipped loading a table if its version
    didn't match GNC_SQL_OBJECT_BACKEND_VERSION which was even more misguided.

diff --git a/libgnucash/backend/sql/gnc-account-sql.cpp b/libgnucash/backend/sql/gnc-account-sql.cpp
index 7f2bde0..f0113ed 100644
--- a/libgnucash/backend/sql/gnc-account-sql.cpp
+++ b/libgnucash/backend/sql/gnc-account-sql.cpp
@@ -101,7 +101,7 @@ static EntryVec parent_col_table
 });
 
 GncSqlAccountBackend::GncSqlAccountBackend() :
-    GncSqlObjectBackend(GNC_SQL_BACKEND_VERSION, GNC_ID_ACCOUNT,
+    GncSqlObjectBackend(TABLE_VERSION, GNC_ID_ACCOUNT,
                         TABLE_NAME, col_table) {}
 
 struct ParentGuid
diff --git a/libgnucash/backend/sql/gnc-bill-term-sql.cpp b/libgnucash/backend/sql/gnc-bill-term-sql.cpp
index 8d77b94..ae813d8 100644
--- a/libgnucash/backend/sql/gnc-bill-term-sql.cpp
+++ b/libgnucash/backend/sql/gnc-bill-term-sql.cpp
@@ -103,7 +103,7 @@ static EntryVec billterm_parent_col_table
 };
 
 GncSqlBillTermBackend::GncSqlBillTermBackend() :
-        GncSqlObjectBackend(GNC_SQL_BACKEND_VERSION, GNC_ID_BILLTERM,
+        GncSqlObjectBackend(TABLE_VERSION, GNC_ID_BILLTERM,
                             TABLE_NAME, col_table) {}
 
 struct BillTermParentGuid
@@ -315,7 +315,7 @@ GncSqlBillTermBackend::create_tables (GncSqlBackend* sql_be)
     {
         sql_be->create_table(TABLE_NAME, TABLE_VERSION, col_table);
     }
-    else if (version == 1)
+    else if (version < m_version)
     {
         /* Upgrade 64 bit int handling */
         sql_be->upgrade_table(TABLE_NAME, col_table);
diff --git a/libgnucash/backend/sql/gnc-book-sql.cpp b/libgnucash/backend/sql/gnc-book-sql.cpp
index bfe8ee6..d38487d 100644
--- a/libgnucash/backend/sql/gnc-book-sql.cpp
+++ b/libgnucash/backend/sql/gnc-book-sql.cpp
@@ -73,7 +73,7 @@ static const EntryVec col_table
 };
 
 GncSqlBookBackend::GncSqlBookBackend() :
-    GncSqlObjectBackend(GNC_SQL_BACKEND_VERSION, GNC_ID_BOOK,
+    GncSqlObjectBackend(TABLE_VERSION, GNC_ID_BOOK,
                         BOOK_TABLE, col_table) {}
 
 /* ================================================================= */
diff --git a/libgnucash/backend/sql/gnc-budget-sql.cpp b/libgnucash/backend/sql/gnc-budget-sql.cpp
index 48f1a8e..9ad5fba 100644
--- a/libgnucash/backend/sql/gnc-budget-sql.cpp
+++ b/libgnucash/backend/sql/gnc-budget-sql.cpp
@@ -81,7 +81,7 @@ static gnc_numeric get_amount (gpointer pObj);
 static void set_amount (gpointer pObj, gnc_numeric value);
 
 GncSqlBudgetBackend::GncSqlBudgetBackend() :
-    GncSqlObjectBackend(GNC_SQL_BACKEND_VERSION, GNC_ID_BUDGET,
+    GncSqlObjectBackend(TABLE_VERSION, GNC_ID_BUDGET,
                         BUDGET_TABLE, col_table) {}
 
 typedef struct
diff --git a/libgnucash/backend/sql/gnc-commodity-sql.cpp b/libgnucash/backend/sql/gnc-commodity-sql.cpp
index 45a710d..dad6877 100644
--- a/libgnucash/backend/sql/gnc-commodity-sql.cpp
+++ b/libgnucash/backend/sql/gnc-commodity-sql.cpp
@@ -88,7 +88,7 @@ static const EntryVec col_table
 };
 
 GncSqlCommodityBackend::GncSqlCommodityBackend() :
-    GncSqlObjectBackend(GNC_SQL_BACKEND_VERSION, GNC_ID_COMMODITY,
+    GncSqlObjectBackend(TABLE_VERSION, GNC_ID_COMMODITY,
                         COMMODITIES_TABLE, col_table) {}
 /* ================================================================= */
 
diff --git a/libgnucash/backend/sql/gnc-customer-sql.cpp b/libgnucash/backend/sql/gnc-customer-sql.cpp
index ce19873..de713eb 100644
--- a/libgnucash/backend/sql/gnc-customer-sql.cpp
+++ b/libgnucash/backend/sql/gnc-customer-sql.cpp
@@ -94,7 +94,7 @@ static EntryVec col_table
 });
 
 GncSqlCustomerBackend::GncSqlCustomerBackend() :
-    GncSqlObjectBackend(GNC_SQL_BACKEND_VERSION, GNC_ID_CUSTOMER,
+    GncSqlObjectBackend(TABLE_VERSION, GNC_ID_CUSTOMER,
                         TABLE_NAME, col_table) {}
 
 static GncCustomer*
@@ -152,7 +152,7 @@ GncSqlCustomerBackend::create_tables (GncSqlBackend* sql_be)
     {
         sql_be->create_table(TABLE_NAME, TABLE_VERSION, col_table);
     }
-    else if (version == 1)
+    else if (version < m_version)
     {
         /* Upgrade 64 bit int handling */
         sql_be->upgrade_table(TABLE_NAME, col_table);
diff --git a/libgnucash/backend/sql/gnc-employee-sql.cpp b/libgnucash/backend/sql/gnc-employee-sql.cpp
index 6b72eba..79c6346 100644
--- a/libgnucash/backend/sql/gnc-employee-sql.cpp
+++ b/libgnucash/backend/sql/gnc-employee-sql.cpp
@@ -79,7 +79,7 @@ static EntryVec col_table
 });
 
 GncSqlEmployeeBackend::GncSqlEmployeeBackend() :
-    GncSqlObjectBackend(GNC_SQL_BACKEND_VERSION, GNC_ID_EMPLOYEE,
+    GncSqlObjectBackend(TABLE_VERSION, GNC_ID_EMPLOYEE,
                         TABLE_NAME, col_table) {}
 
 static GncEmployee*
@@ -138,7 +138,7 @@ GncSqlEmployeeBackend::create_tables (GncSqlBackend* sql_be)
     {
         sql_be->create_table(TABLE_NAME, TABLE_VERSION, col_table);
     }
-    else if (version == 1)
+    else if (version < m_version)
     {
         /* Upgrade 64 bit int handling */
         sql_be->upgrade_table(TABLE_NAME, col_table);
diff --git a/libgnucash/backend/sql/gnc-entry-sql.cpp b/libgnucash/backend/sql/gnc-entry-sql.cpp
index dd40f22..c8be0d9 100644
--- a/libgnucash/backend/sql/gnc-entry-sql.cpp
+++ b/libgnucash/backend/sql/gnc-entry-sql.cpp
@@ -129,7 +129,7 @@ static EntryVec col_table
 });
 
 GncSqlEntryBackend::GncSqlEntryBackend() :
-    GncSqlObjectBackend(GNC_SQL_BACKEND_VERSION, GNC_ID_ENTRY,
+    GncSqlObjectBackend(TABLE_VERSION, GNC_ID_ENTRY,
                         TABLE_NAME, col_table) {}
 
 static void
diff --git a/libgnucash/backend/sql/gnc-invoice-sql.cpp b/libgnucash/backend/sql/gnc-invoice-sql.cpp
index 662b30f..5cfffad 100644
--- a/libgnucash/backend/sql/gnc-invoice-sql.cpp
+++ b/libgnucash/backend/sql/gnc-invoice-sql.cpp
@@ -101,7 +101,7 @@ static EntryVec col_table
 });
 
 GncSqlInvoiceBackend::GncSqlInvoiceBackend() :
-    GncSqlObjectBackend(GNC_SQL_BACKEND_VERSION, GNC_ID_INVOICE,
+    GncSqlObjectBackend(TABLE_VERSION, GNC_ID_INVOICE,
                         TABLE_NAME, col_table) {}
 
 static GncInvoice*
diff --git a/libgnucash/backend/sql/gnc-job-sql.cpp b/libgnucash/backend/sql/gnc-job-sql.cpp
index bb0589f..dd4d9f5 100644
--- a/libgnucash/backend/sql/gnc-job-sql.cpp
+++ b/libgnucash/backend/sql/gnc-job-sql.cpp
@@ -73,7 +73,7 @@ static EntryVec col_table
 });
 
 GncSqlJobBackend::GncSqlJobBackend() :
-    GncSqlObjectBackend(GNC_SQL_BACKEND_VERSION, GNC_ID_JOB,
+    GncSqlObjectBackend(TABLE_VERSION, GNC_ID_JOB,
                         TABLE_NAME, col_table) {}
 
 static GncJob*
diff --git a/libgnucash/backend/sql/gnc-lots-sql.cpp b/libgnucash/backend/sql/gnc-lots-sql.cpp
index f341f6c..322ff85 100644
--- a/libgnucash/backend/sql/gnc-lots-sql.cpp
+++ b/libgnucash/backend/sql/gnc-lots-sql.cpp
@@ -68,7 +68,7 @@ static const EntryVec col_table
 });
 
 GncSqlLotsBackend::GncSqlLotsBackend() :
-    GncSqlObjectBackend(GNC_SQL_BACKEND_VERSION, GNC_ID_LOT,
+    GncSqlObjectBackend(TABLE_VERSION, GNC_ID_LOT,
                         TABLE_NAME, col_table) {}
 
 /* ================================================================= */
@@ -156,7 +156,7 @@ GncSqlLotsBackend::create_tables (GncSqlBackend* sql_be)
         /* The table doesn't exist, so create it */
         (void)sql_be->create_table(TABLE_NAME, TABLE_VERSION, col_table);
     }
-    else if (version == 1)
+    else if (version < m_version)
     {
         /* Version 1 -> 2 removes the 'NOT NULL' constraint on the account_guid
         field.
diff --git a/libgnucash/backend/sql/gnc-order-sql.cpp b/libgnucash/backend/sql/gnc-order-sql.cpp
index bd7c252..b870a22 100644
--- a/libgnucash/backend/sql/gnc-order-sql.cpp
+++ b/libgnucash/backend/sql/gnc-order-sql.cpp
@@ -75,7 +75,7 @@ static EntryVec col_table
 });
 
 GncSqlOrderBackend::GncSqlOrderBackend() :
-    GncSqlObjectBackend(GNC_SQL_BACKEND_VERSION, GNC_ID_ORDER,
+    GncSqlObjectBackend(TABLE_VERSION, GNC_ID_ORDER,
                         TABLE_NAME, col_table) {}
 
 static GncOrder*
diff --git a/libgnucash/backend/sql/gnc-price-sql.cpp b/libgnucash/backend/sql/gnc-price-sql.cpp
index ffcc691..eaf99eb 100644
--- a/libgnucash/backend/sql/gnc-price-sql.cpp
+++ b/libgnucash/backend/sql/gnc-price-sql.cpp
@@ -71,7 +71,7 @@ static const EntryVec col_table
 });
 
 GncSqlPriceBackend::GncSqlPriceBackend() :
-    GncSqlObjectBackend(GNC_SQL_BACKEND_VERSION, GNC_ID_PRICE,
+    GncSqlObjectBackend(TABLE_VERSION, GNC_ID_PRICE,
                         TABLE_NAME, col_table) {}
 
 /* ================================================================= */
@@ -146,7 +146,7 @@ GncSqlPriceBackend::create_tables (GncSqlBackend* sql_be)
     {
         (void)sql_be->create_table(TABLE_NAME, TABLE_VERSION, col_table);
     }
-    else if (version == 1)
+    else if (version < m_version)
     {
         /* Upgrade 64 bit int handling */
         sql_be->upgrade_table(TABLE_NAME, col_table);
diff --git a/libgnucash/backend/sql/gnc-recurrence-sql.cpp b/libgnucash/backend/sql/gnc-recurrence-sql.cpp
index e6c9f76..892b83d 100644
--- a/libgnucash/backend/sql/gnc-recurrence-sql.cpp
+++ b/libgnucash/backend/sql/gnc-recurrence-sql.cpp
@@ -117,7 +117,7 @@ static const EntryVec weekend_adjust_col_table
  * write() implementation is also a no-op.
  */
 GncSqlRecurrenceBackend::GncSqlRecurrenceBackend() :
-        GncSqlObjectBackend(GNC_SQL_BACKEND_VERSION, GNC_ID_ACCOUNT, TABLE_NAME, col_table) {}
+        GncSqlObjectBackend(TABLE_VERSION, GNC_ID_ACCOUNT, TABLE_NAME, col_table) {}
 
 /* ================================================================= */
 
@@ -415,7 +415,7 @@ GncSqlRecurrenceBackend::create_tables (GncSqlBackend* sql_be)
         /* Upgrade:
             1->2: Add recurrence_weekend_adjust field (mandatory, non-null field)
         */
-        if (version == 1)
+        if (version < m_version)
         {
             upgrade_recurrence_table_1_2 (sql_be);
         }
diff --git a/libgnucash/backend/sql/gnc-schedxaction-sql.cpp b/libgnucash/backend/sql/gnc-schedxaction-sql.cpp
index a4ec238..f7909fd 100644
--- a/libgnucash/backend/sql/gnc-schedxaction-sql.cpp
+++ b/libgnucash/backend/sql/gnc-schedxaction-sql.cpp
@@ -85,7 +85,7 @@ static const EntryVec col_table
 });
 
 GncSqlSchedXactionBackend::GncSqlSchedXactionBackend() :
-    GncSqlObjectBackend(GNC_SQL_BACKEND_VERSION, GNC_ID_SCHEDXACTION,
+    GncSqlObjectBackend(TABLE_VERSION, GNC_ID_SCHEDXACTION,
                         SCHEDXACTION_TABLE, col_table) {}
 
 /* ================================================================= */
diff --git a/libgnucash/backend/sql/gnc-slots-sql.cpp b/libgnucash/backend/sql/gnc-slots-sql.cpp
index 79cc038..7cd80fd 100644
--- a/libgnucash/backend/sql/gnc-slots-sql.cpp
+++ b/libgnucash/backend/sql/gnc-slots-sql.cpp
@@ -180,7 +180,7 @@ static const EntryVec gdate_col_table
 };
 
 GncSqlSlotsBackend::GncSqlSlotsBackend() :
-    GncSqlObjectBackend(GNC_SQL_BACKEND_VERSION, GNC_ID_ACCOUNT,
+    GncSqlObjectBackend(TABLE_VERSION, GNC_ID_ACCOUNT,
                         TABLE_NAME, col_table) {}
 
 /* ================================================================= */
@@ -982,6 +982,10 @@ GncSqlSlotsBackend::create_tables (GncSqlBackend* sql_be)
                 PERR ("Unable to add gdate column\n");
             }
         }
+        else if (version < m_version)
+        {
+            sql_be->upgrade_table(TABLE_NAME, col_table);
+        }
         sql_be->set_table_version (TABLE_NAME, TABLE_VERSION);
         PINFO ("Slots table upgraded from version %d to version %d\n", version,
                TABLE_VERSION);
diff --git a/libgnucash/backend/sql/gnc-sql-backend.cpp b/libgnucash/backend/sql/gnc-sql-backend.cpp
index 2acf218..3af2d3e 100644
--- a/libgnucash/backend/sql/gnc-sql-backend.cpp
+++ b/libgnucash/backend/sql/gnc-sql-backend.cpp
@@ -224,7 +224,6 @@ GncSqlBackend::ObjectBackendRegistry::load_remaining(GncSqlBackend* sql_be)
         std::string type;
         GncSqlObjectBackendPtr obe = nullptr;
         std::tie(type, obe) = entry;
-        if (!obe->is_version(GNC_SQL_BACKEND_VERSION)) continue;
 
         /* Don't need to load anything if it has already been loaded with
          * the fixed order.
diff --git a/libgnucash/backend/sql/gnc-sql-object-backend.hpp b/libgnucash/backend/sql/gnc-sql-object-backend.hpp
index 59d10ce..b6a007e 100644
--- a/libgnucash/backend/sql/gnc-sql-object-backend.hpp
+++ b/libgnucash/backend/sql/gnc-sql-object-backend.hpp
@@ -38,7 +38,6 @@ using GncSqlColumnTableEntryPtr = std::shared_ptr<GncSqlColumnTableEntry>;
 using EntryVec = std::vector<GncSqlColumnTableEntryPtr>;
 
 #define GNC_SQL_BACKEND "gnc:sql:1"
-#define GNC_SQL_BACKEND_VERSION 1
 
 /**
  * Encapsulates per-class table schema with functions to load, create a table,
diff --git a/libgnucash/backend/sql/gnc-tax-table-sql.cpp b/libgnucash/backend/sql/gnc-tax-table-sql.cpp
index 1030d2c..818ab84 100644
--- a/libgnucash/backend/sql/gnc-tax-table-sql.cpp
+++ b/libgnucash/backend/sql/gnc-tax-table-sql.cpp
@@ -121,7 +121,7 @@ static EntryVec guid_col_table
 });
 
 GncSqlTaxTableBackend::GncSqlTaxTableBackend() :
-    GncSqlObjectBackend(GNC_SQL_BACKEND_VERSION, GNC_ID_TAXTABLE,
+    GncSqlObjectBackend(TT_TABLE_VERSION, GNC_ID_TAXTABLE,
                         TT_TABLE_NAME, tt_col_table) {}
 
 struct TaxTblParentGuid
@@ -345,7 +345,7 @@ GncSqlTaxTableBackend::create_tables (GncSqlBackend* sql_be)
     {
         sql_be->create_table(TT_TABLE_NAME, TT_TABLE_VERSION, tt_col_table);
     }
-    else if (version == 1)
+    else if (version < m_version)
     {
         /* Upgrade 64 bit int handling */
         sql_be->upgrade_table(TT_TABLE_NAME, tt_col_table);
@@ -360,7 +360,7 @@ GncSqlTaxTableBackend::create_tables (GncSqlBackend* sql_be)
         sql_be->create_table(TTENTRIES_TABLE_NAME, TTENTRIES_TABLE_VERSION,
                               ttentries_col_table);
     }
-    else if (version == 1)
+    else if (version < TTENTRIES_TABLE_VERSION)
     {
         /* Upgrade 64 bit int handling */
         sql_be->upgrade_table(TTENTRIES_TABLE_NAME, ttentries_col_table);
diff --git a/libgnucash/backend/sql/gnc-transaction-sql.cpp b/libgnucash/backend/sql/gnc-transaction-sql.cpp
index 5fc8a43..e3ff00f 100644
--- a/libgnucash/backend/sql/gnc-transaction-sql.cpp
+++ b/libgnucash/backend/sql/gnc-transaction-sql.cpp
@@ -143,11 +143,11 @@ static const EntryVec tx_guid_col_table
 };
 
 GncSqlTransBackend::GncSqlTransBackend() :
-    GncSqlObjectBackend(GNC_SQL_BACKEND_VERSION, GNC_ID_TRANS,
+    GncSqlObjectBackend(TX_TABLE_VERSION, GNC_ID_TRANS,
                         TRANSACTION_TABLE, tx_col_table) {}
 
 GncSqlSplitBackend::GncSqlSplitBackend() :
-    GncSqlObjectBackend(GNC_SQL_BACKEND_VERSION, GNC_ID_SPLIT,
+    GncSqlObjectBackend(SPLIT_TABLE_VERSION, GNC_ID_SPLIT,
                         SPLIT_TABLE, split_col_table) {}
 
 /* These functions exist but have not been tested.
diff --git a/libgnucash/backend/sql/gnc-vendor-sql.cpp b/libgnucash/backend/sql/gnc-vendor-sql.cpp
index 9bdb07b..ae60b3a 100644
--- a/libgnucash/backend/sql/gnc-vendor-sql.cpp
+++ b/libgnucash/backend/sql/gnc-vendor-sql.cpp
@@ -83,7 +83,7 @@ static EntryVec col_table
 });
 
 GncSqlVendorBackend::GncSqlVendorBackend() :
-    GncSqlObjectBackend(GNC_SQL_BACKEND_VERSION, GNC_ID_VENDOR,
+    GncSqlObjectBackend(TABLE_VERSION, GNC_ID_VENDOR,
                         TABLE_NAME, col_table) {}
 
 static GncVendor*



Summary of changes:
 libgnucash/backend/dbi/gnc-dbiproviderimpl.hpp    |  2 +-
 libgnucash/backend/sql/gnc-account-sql.cpp        |  2 +-
 libgnucash/backend/sql/gnc-bill-term-sql.cpp      |  4 ++--
 libgnucash/backend/sql/gnc-book-sql.cpp           |  2 +-
 libgnucash/backend/sql/gnc-budget-sql.cpp         |  2 +-
 libgnucash/backend/sql/gnc-commodity-sql.cpp      |  2 +-
 libgnucash/backend/sql/gnc-customer-sql.cpp       |  4 ++--
 libgnucash/backend/sql/gnc-employee-sql.cpp       |  4 ++--
 libgnucash/backend/sql/gnc-entry-sql.cpp          |  5 +++--
 libgnucash/backend/sql/gnc-invoice-sql.cpp        |  5 +++--
 libgnucash/backend/sql/gnc-job-sql.cpp            |  2 +-
 libgnucash/backend/sql/gnc-lots-sql.cpp           |  4 ++--
 libgnucash/backend/sql/gnc-order-sql.cpp          |  2 +-
 libgnucash/backend/sql/gnc-price-sql.cpp          | 11 +++++++----
 libgnucash/backend/sql/gnc-recurrence-sql.cpp     |  4 ++--
 libgnucash/backend/sql/gnc-schedxaction-sql.cpp   |  2 +-
 libgnucash/backend/sql/gnc-slots-sql.cpp          | 11 ++++++++---
 libgnucash/backend/sql/gnc-sql-backend.cpp        |  1 -
 libgnucash/backend/sql/gnc-sql-object-backend.hpp |  1 -
 libgnucash/backend/sql/gnc-tax-table-sql.cpp      |  6 +++---
 libgnucash/backend/sql/gnc-transaction-sql.cpp    |  7 ++++---
 libgnucash/backend/sql/gnc-vendor-sql.cpp         |  2 +-
 22 files changed, 47 insertions(+), 38 deletions(-)



More information about the gnucash-changes mailing list