private void CheckCacheTable() { if (CacheTableName == checked_cache_table) { return; } if (!connection.TableExists(CacheTableName)) { connection.Execute(String.Format(@" CREATE TEMP TABLE {0} ( OrderID INTEGER PRIMARY KEY, ModelID INTEGER, ItemID TEXT)", CacheTableName )); } if (!connection.TableExists(CacheModelsTableName)) { connection.Execute(String.Format( "CREATE TABLE {0} (CacheID INTEGER PRIMARY KEY, ModelID TEXT UNIQUE)", CacheModelsTableName )); } checked_cache_table = CacheTableName; }
protected virtual void CheckVersion() { if (Connection.TableExists(HyenaTableName)) { using (var reader = Connection.Query(SelectVersionSql(TableName))) { if (reader.Read()) { int table_version = reader.Get <int> (0); if (table_version < ModelVersion) { MigrateTable(table_version); UpdateVersion(TableName, ModelVersion); } } else { InsertVersion(TableName, ModelVersion); } } int db_version = Connection.Query <int> (SelectVersionSql(HYENA_DATABASE_NAME)); if (db_version < DatabaseVersion) { MigrateDatabase(db_version); UpdateVersion(HYENA_DATABASE_NAME, DatabaseVersion); } } else { Connection.Execute(string.Format( @"CREATE TABLE {0} ( id INTEGER PRIMARY KEY, name TEXT UNIQUE, version INTEGER)", HyenaTableName) ); InsertVersion(HYENA_DATABASE_NAME, DatabaseVersion); InsertVersion(TableName, ModelVersion); } }