return CDatabase::Open();
}
-bool CTextureDatabase::CreateTables()
+void CTextureDatabase::CreateTables()
{
- try
- {
- CDatabase::CreateTables();
-
CLog::Log(LOGINFO, "create texture table");
m_pDS->exec("CREATE TABLE texture (id integer primary key, url text, cachedurl text, imagehash text, lasthashcheck text)");
// TODO: Should the path index be a covering index? (we need only retrieve texture)
CLog::Log(LOGINFO, "create path index");
m_pDS->exec("CREATE INDEX idxPath ON path(url, type)");
- }
- catch (...)
- {
- CLog::Log(LOGERROR, "%s unable to create tables", __FUNCTION__);
- return false;
- }
-
- return true;
}
bool CTextureDatabase::UpdateOldVersion(int version)
*/
unsigned int GetURLHash(const CStdString &url) const;
- virtual bool CreateTables();
+ virtual void CreateTables();
virtual bool UpdateOldVersion(int version);
virtual int GetMinVersion() const { return 13; };
const char *GetBaseDBName() const { return "Textures"; };
return CDatabase::Open();
}
-bool CAddonDatabase::CreateTables()
+void CAddonDatabase::CreateTables()
{
- try
- {
- CDatabase::CreateTables();
-
CLog::Log(LOGINFO, "create addon table");
m_pDS->exec("CREATE TABLE addon (id integer primary key, type text,"
"name text, summary text, description text, stars integer,"
CLog::Log(LOGINFO, "create package table");
m_pDS->exec("CREATE TABLE package (id integer primary key, addonID text, filename text, hash text)\n");
m_pDS->exec("CREATE UNIQUE INDEX idxPackage ON package(filename)");
- }
- catch (...)
- {
- CLog::Log(LOGERROR, "%s unable to create tables", __FUNCTION__);
- return false;
- }
-
- return true;
}
bool CAddonDatabase::UpdateOldVersion(int version)
*/
bool RemovePackage(const CStdString& packageFileName);
protected:
- virtual bool CreateTables();
+ virtual void CreateTables();
virtual bool UpdateOldVersion(int version);
virtual int GetMinVersion() const { return 16; }
const char *GetBaseDBName() const { return "Addons"; }
// Also set the memory cache size to 16k
m_pDS->exec("PRAGMA default_cache_size=4096\n");
}
- CreateTables();
+ CreateDatabase();
}
// sqlite3 post connection operations
return m_pDB->in_transaction();
}
-bool CDatabase::CreateTables()
+bool CDatabase::CreateDatabase()
{
-
+ BeginTransaction();
+ try
+ {
CLog::Log(LOGINFO, "creating version table");
m_pDS->exec("CREATE TABLE version (idVersion integer, iCompressCount integer)\n");
CStdString strSQL=PrepareSQL("INSERT INTO version (idVersion,iCompressCount) values(%i,0)\n", GetMinVersion());
m_pDS->exec(strSQL.c_str());
- return true;
+ CreateTables();
+ }
+ catch (...)
+ {
+ CLog::Log(LOGERROR, "%s unable to create database:%i", __FUNCTION__, (int)GetLastError());
+ RollbackTransaction();
+ return false;
+ }
+ CommitTransaction();
+ return true;
}
bool CDatabase::UpdateVersionNumber()
uint32_t ComputeCRC(const CStdString &text);
virtual bool Open();
- virtual bool CreateTables();
- virtual void CreateViews() {};
+
+ /*! \brief Create database tables and analytics as needed.
+ Calls CreateTables() on child classes.
+ */
+ bool CreateDatabase();
+
+ /* \brief Create tables for the current database schema.
+ Will be called on database creation.
+ */
+ virtual void CreateTables()=0;
+
virtual bool UpdateOldVersion(int version) { return true; };
virtual int GetMinVersion() const=0;
return CDatabase::Open(g_advancedSettings.m_databaseEpg);
}
-bool CEpgDatabase::CreateTables(void)
+void CEpgDatabase::CreateTables(void)
{
- bool bReturn(false);
-
- try
- {
- CDatabase::CreateTables();
-
- BeginTransaction();
-
CLog::Log(LOGINFO, "EpgDB - %s - creating tables", __FUNCTION__);
CLog::Log(LOGDEBUG, "EpgDB - %s - creating table 'epg'", __FUNCTION__);
"sLastScan varchar(20)"
")"
);
-
- CommitTransaction();
-
- bReturn = true;
- }
- catch (...)
- {
- CLog::Log(LOGERROR, "EpgDB - %s - unable to create EPG tables:%i",
- __FUNCTION__, (int)GetLastError());
- RollbackTransaction();
- bReturn = false;
- }
-
- return bReturn;
}
bool CEpgDatabase::UpdateOldVersion(int iVersion)
protected:
/*!
* @brief Create the EPG database tables.
- * @return True if the tables were created successfully, false otherwise.
*/
- virtual bool CreateTables(void);
+ virtual void CreateTables();
/*!
* @brief Update an old version of the database.
return CDatabase::Open(g_advancedSettings.m_databaseMusic);
}
-bool CMusicDatabase::CreateTables()
+void CMusicDatabase::CreateTables()
{
- BeginTransaction();
- try
- {
- CDatabase::CreateTables();
-
CLog::Log(LOGINFO, "create artist table");
m_pDS->exec("CREATE TABLE artist ( idArtist integer primary key, "
" strArtist varchar(256), strMusicBrainzArtistID text, "
// Add 'Karaoke' genre
AddGenre( "Karaoke" );
- }
- catch (...)
- {
- CLog::Log(LOGERROR, "%s unable to create tables:%i", __FUNCTION__, (int)GetLastError());
- RollbackTransaction();
- return false;
- }
- CommitTransaction();
- return true;
}
void CMusicDatabase::CreateViews()
std::map<CStdString, int> m_thumbCache;
std::map<CStdString, CAlbum> m_albumCache;
- virtual bool CreateTables();
+ virtual void CreateTables();
virtual int GetMinVersion() const;
const char *GetBaseDBName() const { return "MyMusic"; };
return CDatabase::Open(g_advancedSettings.m_databaseTV);
}
-bool CPVRDatabase::CreateTables()
+void CPVRDatabase::CreateTables()
{
- bool bReturn(false);
-
- try
- {
- if (!CDatabase::CreateTables())
- return false;
-
- BeginTransaction();
CLog::Log(LOGINFO, "PVR - %s - creating tables", __FUNCTION__);
CLog::Log(LOGDEBUG, "PVR - %s - creating table 'clients'", __FUNCTION__);
")"
);
- CommitTransaction();
- bReturn = true;
- }
- catch (...)
- {
- CLog::Log(LOGERROR, "PVR - %s - unable to create PVR database tables (error %i)", __FUNCTION__, (int)GetLastError());
- RollbackTransaction();
- bReturn = false;
- }
-
- if (bReturn)
- {
// disable all PVR add-on when started the first time
ADDON::VECADDONS addons;
- if ((bReturn = CAddonMgr::Get().GetAddons(ADDON_PVRDLL, addons, true)) == false)
+ if (!CAddonMgr::Get().GetAddons(ADDON_PVRDLL, addons, true))
CLog::Log(LOGERROR, "PVR - %s - failed to get add-ons from the add-on manager", __FUNCTION__);
else
{
for (IVECADDONS it = addons.begin(); it != addons.end(); it++)
CAddonMgr::Get().DisableAddon(it->get()->ID());
}
- }
-
- return bReturn;
}
bool CPVRDatabase::UpdateOldVersion(int iVersion)
* @brief Create the PVR database tables.
* @return True if the tables were created successfully, false otherwise.
*/
- bool CreateTables();
+ void CreateTables();
bool DeleteChannelsFromGroup(const CPVRChannelGroup &group);
bool DeleteChannelsFromGroup(const CPVRChannelGroup &group, const std::vector<int> &channelsToDelete);
return CDatabase::Open(g_advancedSettings.m_databaseVideo);
}
-bool CVideoDatabase::CreateTables()
+void CVideoDatabase::CreateTables()
{
/* indexes should be added on any columns that are used in in */
/* a where or a join. primary key on a column is the same as a */
/* advantage of a index that has been created on ( idGenre, idMovie ) */
/*, hower on on ( idMovie, idGenre ) will be considered for use */
- BeginTransaction();
- try
- {
- CDatabase::CreateTables();
-
CLog::Log(LOGINFO, "create bookmark table");
m_pDS->exec("CREATE TABLE bookmark ( idBookmark integer primary key, idFile integer, timeInSeconds double, totalTimeInSeconds double, thumbNailImage text, player text, playerState text, type integer)\n");
m_pDS->exec("CREATE INDEX ix_bookmark ON bookmark (idFile, type)");
// we create views last to ensure all indexes are rolled in
CreateViews();
- }
- catch (...)
- {
- CLog::Log(LOGERROR, "%s unable to create tables:%i", __FUNCTION__, (int)GetLastError());
- RollbackTransaction();
- return false;
- }
- CommitTransaction();
- return true;
}
void CVideoDatabase::CreateViews()
CStdString GetValueString(const CVideoInfoTag &details, int min, int max, const SDbTableOffsets *offsets) const;
private:
- virtual bool CreateTables();
+ virtual void CreateTables();
virtual bool UpdateOldVersion(int version);
/*! \brief (Re)Create the generic database views for movies, tvshows,
return CDatabase::Open();
}
-bool CViewDatabase::CreateTables()
+void CViewDatabase::CreateTables()
{
- try
- {
- CDatabase::CreateTables();
-
CLog::Log(LOGINFO, "create view table");
m_pDS->exec("CREATE TABLE view ("
"idView integer primary key,"
m_pDS->exec("CREATE INDEX idxViews ON view(path)");
CLog::Log(LOGINFO, "create view - window index");
m_pDS->exec("CREATE INDEX idxViewsWindow ON view(window)");
- }
- catch (...)
- {
- CLog::Log(LOGERROR, "%s unable to create tables:%u",
- __FUNCTION__, GetLastError());
- return false;
- }
-
- return true;
}
bool CViewDatabase::UpdateOldVersion(int version)
bool ClearViewStates(int windowID);
protected:
- virtual bool CreateTables();
+ virtual void CreateTables();
virtual bool UpdateOldVersion(int version);
virtual int GetMinVersion() const { return 6; };
const char *GetBaseDBName() const { return "ViewModes"; };