def compile(self, db = None): if not isinstance(db, (base.minion_database_base)): # // Get the database instance db = base.instance(db) value = self.value() if len(self._parameters) > 0: # // Quote all of the parameter values params = dict() for key in self._parameters: params[key] = db.quote(self._parameters[key]) value = strtr(value, params) return value
def execute(self, config): k_config = migration_conf.conf() groups = config.get("group") target = config.get("to") dry_run = False quiet = False up = False down = False if config.get("dry-run"): dry_run = True if config.get("quiet"): quiet = True if config.get("up"): up = True if config.get("down"): down = True groups = self._parse_groups(groups) if target is None: if down: target = False else: target = True db = database.instance() model = migration_model(db) model.ensure_table_exists() manager = minion_migration_manager(db, model) # Sync the available migrations with those in the db manager.sync_migration_files().set_dry_run(dry_run) try: # // Run migrations for specified groups & versions manager.run_migrations(groups, target) except minion_migration_exception as e: raise e
def execute(self, db=None, as_object=None, object_params=None): if not isinstance(db, (base.minion_database_base)): # // Get the database instance db = base.instance(db) # if ($as_object === NULL) # { # $as_object = $this->_as_object; # } # if ($object_params === NULL) # { # $object_params = $this->_object_params; # } # // Compile the SQL query sql = self.compile(db) # if ($this->_lifetime !== NULL AND $this->_type === Database::SELECT) # { # // Set the cache key based on the database instance name and SQL # $cache_key = 'Database::query("'.$db.'", "'.$sql.'")'; # # // Read the cache first to delete a possible hit with lifetime <= 0 # if (($result = Kohana::cache($cache_key, NULL, $this->_lifetime)) !== NULL # AND ! $this->_force_execute) # { # // Return a cached result # return new Database_Result_Cached($result, $sql, $as_object, $object_params); # } # } # # // Execute the query result = db.query(self._type, sql, as_object, object_params) # # if (isset($cache_key) AND $this->_lifetime > 0) # { # // Cache the result array # Kohana::cache($cache_key, $result->as_array(), $this->_lifetime); # } # return result