mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
/* ================================================================= */
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {}
|
||||
/* ================================================================= */
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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*
|
||||
|
||||
@@ -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*
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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*
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
/* ================================================================= */
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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*
|
||||
|
||||
Reference in New Issue
Block a user