Esempio n. 1
0
 protected void CreateIndex(string name, string columns)
 {
     Connection.Execute(String.Format(
                            "CREATE INDEX {0} ON {1} ({2})",
                            name, TableName, columns
                            ));
 }
        public override void Reload()
        {
            lock (this) {
                if (last_reload_fragment != model.ReloadFragment || last_reload_command == null)
                {
                    last_reload_fragment = model.ReloadFragment;
                    last_reload_command  = new HyenaSqliteCommand(String.Format("{0}{1}", reload_sql, last_reload_fragment));
                }

                Clear();
                //Log.DebugFormat ("Reloading {0} with {1}", model, last_reload_command.Text);
                connection.Execute(last_reload_command);
            }
        }
Esempio n. 3
0
        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);
            }
        }