Downgrade assets db by adding a not null constraint on
    ``equities.first_traded``
553043
def _downgrade_v3(op):
    
    op.create_table(
        '_new_equities',
        sa.Column(
            'sid',
            sa.Integer,
            unique=True,
            nullable=False,
            primary_key=True,
        ),
        sa.Column('symbol', sa.Text),
        sa.Column('company_symbol', sa.Text),
        sa.Column('share_class_symbol', sa.Text),
        sa.Column('fuzzy_symbol', sa.Text),
        sa.Column('asset_name', sa.Text),
        sa.Column('start_date', sa.Integer, default=0, nullable=False),
        sa.Column('end_date', sa.Integer, nullable=False),
        sa.Column('first_traded', sa.Integer, nullable=False),
        sa.Column('auto_close_date', sa.Integer),
        sa.Column('exchange', sa.Text),
    )
    op.execute(
        """
        insert into _new_equities
        select * from equities
        where equities.first_traded is not null
        """,
    )
    op.drop_table('equities')
    op.rename_table('_new_equities', 'equities')
    # we need to make sure the indices have the proper names after the rename
    op.create_index(
        'ix_equities_company_symbol',
        'equities',
        ['company_symbol'],
    )
    op.create_index(
        'ix_equities_fuzzy_symbol',
        'equities',
        ['fuzzy_symbol'],
    )
181969
def validate(self,
                 asset,
                 amount,
                 portfolio,
                 algo_datetime,
                 algo_current_data):
        
        # If the order is for 0 shares, then silently pass through.
        if amount == 0:
            return

        normalized_algo_dt = pd.Timestamp(algo_datetime).normalize()

        # Fail if the algo is before this Asset's start_date
        if asset.start_date:
            normalized_start = pd.Timestamp(asset.start_date).normalize()
            if normalized_algo_dt < normalized_start:
                metadata = {
                    'asset_start_date': normalized_start
                }
                self.handle_violation(
                    asset, amount, algo_datetime, metadata=metadata)
        # Fail if the algo has passed this Asset's end_date
        if asset.end_date:
            normalized_end = pd.Timestamp(asset.end_date).normalize()
            if normalized_algo_dt > normalized_end:
                metadata = {
                    'asset_end_date': normalized_end
                }
                self.handle_violation(
                    asset, amount, algo_datetime, metadata=metadata)
144640
def downgrade():
    """"""
    # table ObjectVersionTag
    op.drop_table('files_objecttags')
    # table ObjectVersion: modify primary_key
    if op.get_context().dialect.name == 'mysql':
        op.execute(
            'ALTER TABLE files_object '
            'DROP INDEX uq_files_object_bucket_id, '
            'DROP PRIMARY KEY, '
            'ADD PRIMARY KEY(`bucket_id`, `key`, `version_id`)')
    else:
        op.drop_constraint(
            'pk_files_object', 'files_object', type_='primary')
        op.create_primary_key('pk_files_object', 'files_object',
                              ['bucket_id', 'key', 'version_id'])
346339
def db_downgrade(version):
    """"""
    v1 = get_db_version()
    migrate_api.downgrade(url=db_url, repository=db_repo, version=version)
    v2 = get_db_version()

    if v1 == v2:
        print 'No changes made.'
    else:
        print 'Downgraded: %s ... %s' % (v1, v2)
53323
void rollback()
	{
		switch (data_type)
		{
		case Tango_DEV_BOOLEAN :
			bool_val = old_bool_val;
			break;
		
		case Tango_DEV_SHORT :
			short_val = old_short_val;
			break;
		
		case Tango_DEV_LONG :
			long_val = old_long_val;
			break;
		
		case Tango_DEV_LONG64 :
			long64_val = old_long64_val;
			break;
		
		case Tango_DEV_DOUBLE :
			double_val = old_double_val;
			break;
		
		case Tango_DEV_STRING :
			str_val = old_str_val;
			break;
		}
	}
1297345
function adjustConstraints(oType, oConstraints) {
		var oAdjustedConstraints = {};

		if (oConstraints) {
			switch (oConstraints.displayFormat) {
			case "Date":
				oAdjustedConstraints.isDateOnly = true;
				break;
			case undefined:
				break;
			default:
				Log.warning("Illegal displayFormat: " + oConstraints.displayFormat,
					null, oType.getName());
			}
			oAdjustedConstraints.nullable = oConstraints.nullable;
		}
		return oAdjustedConstraints;
	}
574218
def downgrade(account):
    """"""
    d_account = dict(schema_version=1, metadata={'email': account['email']},
                     tags=list(set([account['environment']] + account.get('tags', []))))

    v1_services = {}
    for service in account.get('services', []):
        if service['name'] == 's3':
            if service['metadata'].get('name'):
                d_account['metadata']['s3_name'] = service['metadata']['name']

        elif service['name'] == 'cloudtrail':
            d_account['metadata']['cloudtrail_index'] = service['metadata']['esIndex']
            d_account['metadata']['cloudtrail_kibana_url'] = service['metadata']['kibanaUrl']

        elif service['name'] == 'bastion':
            d_account['bastion'] = service['metadata']['hostname']

        elif service['name'] == 'titus':
            v1_services['titus'] = {
                'stacks': service['metadata']['stacks'],
                'enabled': service['status'][0]['enabled']
            }

        elif service['name'] == 'spinnaker':
            v1_services['spinnaker'] = {
                'name': service['metadata'].get('name', account["name"]),
                'enabled': service['status'][0]['enabled']
            }

        elif service['name'] == 'awwwdit':
            v1_services['awwwdit'] = {
                'enabled': service['status'][0]['enabled']
            }

        elif service['name'] == 'security_monkey':
            v1_services['security_monkey'] = {
                'enabled': service['status'][0]['enabled']
            }

        elif service['name'] == 'poseidon':
            v1_services['poseidon'] = {
                'enabled': service['status'][0]['enabled']
            }

        elif service['name'] == 'rolliepollie':
            v1_services['rolliepollie'] = {
                'enabled': service['status'][0]['enabled']
            }

        elif service['name'] == 'lazyfalcon':
            owner = None

            if service.get('metadata'):
                if service['metadata'].get('owner'):
                    owner = service['metadata']['owner']

            v1_services['lazyfalcon'] = {
                'enabled': service['status'][0]['enabled'],
                'owner': owner
            }

    if account['provider'] == 'aws':
        d_account['metadata']['account_number'] = account['id']

    elif account['provider'] == 'gcp':
        d_account['metadata']['project_id'] = account['id']

    d_account['id'] = account['provider'] + '-' + account['id']
    d_account['cmc_required'] = account['sensitive']
    d_account['name'] = account['name']
    d_account['alias'] = account['aliases']
    d_account['description'] = account['description']
    d_account['owners'] = account['contacts']
    d_account['type'] = account['provider']
    d_account['ours'] = True if account['owner'] == 'netflix' else False
    d_account['netflix'] = True if account['owner'] == 'netflix' else False
    d_account['services'] = v1_services
    d_account['account_status'] = account['account_status']

    return d_account
811613
public function down()
    {
        // Drop created tables in reverse order

        // Lookup Keys
        Schema::dropIfExists('lookup');
        // System customizations
        Schema::dropIfExists('system_custom');
        // System Configuration
        Schema::dropIfExists('system_config');
        // File storage, public path designation
        Schema::dropIfExists('file_service_config');
        // Cache-able service configuration
        Schema::dropIfExists('service_cache_config');
        // JSON Web Token to system resources map
        Schema::dropIfExists('token_map');
        // App relationship for user
        Schema::dropIfExists('user_to_app_to_role');
        // Service Docs
        Schema::dropIfExists('service_doc');
        // Role Service Accesses
        Schema::dropIfExists('role_service_access');
        // Roles
        Schema::dropIfExists('role');
        // Email Templates
        Schema::dropIfExists('email_template');
        // Services
        Schema::dropIfExists('service');
        //Cors config table
        Schema::dropIfExists('cors_config');
        // App relationship for user
        Schema::dropIfExists('user_to_app_role');
        // Applications
        Schema::dropIfExists('app');
        //Password reset
        Schema::dropIfExists('password_resets');
        // User table
        Schema::dropIfExists('user');
    }
535270
def handle_violation(self, asset, amount, datetime, metadata=None):
        
        constraint = self._constraint_msg(metadata)

        if self.on_error == 'fail':
            raise TradingControlViolation(
                asset=asset,
                amount=amount,
                datetime=datetime,
                constraint=constraint)
        elif self.on_error == 'log':
            log.error("Order for {amount} shares of {asset} at {dt} "
                      "violates trading constraint {constraint}",
                      amount=amount, asset=asset, dt=datetime,
                      constraint=constraint)
421537
def down(tag, sql, revision):
    
    alembic_command.downgrade(
        config=get_config(),
        revision=revision,
        sql=sql,
        tag=tag
    )
158699
private void reverse(WritableDataStore<HashSetModifiableDBIDs> sampleNewHash, WritableDataStore<HashSetModifiableDBIDs> newReverseNeighbors, WritableDataStore<HashSetModifiableDBIDs> oldReverseNeighbors) {
    for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) {
      KNNHeap heap = store.get(iditer);
      HashSetDBIDs newNeighbors = sampleNewHash.get(iditer);
      for(DoubleDBIDListIter heapiter = heap.unorderedIterator(); heapiter.valid(); heapiter.advance()) {
        (newNeighbors.contains(heapiter) ? newReverseNeighbors : oldReverseNeighbors).get(heapiter).add(iditer);
      }
    }
  }
804372
public function downgradeDatabase()
    {
        $config = $this->getConfig();

        // In case reverting the changes, it is also safer to assume that
        // the user might want to setup the manual approval process and
        // therefore disable the public registrations until it has been done.
        if ($config->get('concrete.user.registration.enabled')) {
            $config->save('concrete.user.registration.enabled', false);
            $config->save('concrete.user.registration.type', 'disabled');
        }
    }
1256722
def override_account_fields(self,
                                settled_cash=not_overridden,
                                accrued_interest=not_overridden,
                                buying_power=not_overridden,
                                equity_with_loan=not_overridden,
                                total_positions_value=not_overridden,
                                total_positions_exposure=not_overridden,
                                regt_equity=not_overridden,
                                regt_margin=not_overridden,
                                initial_margin_requirement=not_overridden,
                                maintenance_margin_requirement=not_overridden,
                                available_funds=not_overridden,
                                excess_liquidity=not_overridden,
                                cushion=not_overridden,
                                day_trades_remaining=not_overridden,
                                leverage=not_overridden,
                                net_leverage=not_overridden,
                                net_liquidation=not_overridden):
        
        # mark that the portfolio is dirty to override the fields again
        self._dirty_account = True
        self._account_overrides = kwargs = {
            k: v for k, v in locals().items() if v is not not_overridden
        }
        del kwargs['self']
468940
void makeNewTable(OrderedHashSet dropConstraintSet,
                      OrderedHashSet dropIndexSet) {

        Table tn = table.moveDefinition(session, table.tableType, null, null,
                                        null, -1, 0, dropConstraintSet,
                                        dropIndexSet);

        if (tn.indexList.length == table.indexList.length) {
            database.persistentStoreCollection.releaseStore(tn);

            return;
        }

        tn.moveData(session, table, -1, 0);
        database.persistentStoreCollection.releaseStore(table);

        table = tn;
    }
170636
function normalizeAssets(clientLibPath, assets) {

  var list = assets;

  // transform object to array
  if (!_.isArray(assets)) {
    list = [];
    _.keys(assets).forEach(function (assetKey) {
      var assetItem = assets[assetKey];

      // check/transform short version
      if (_.isArray(assetItem)) {
        assetItem = {
          files: assetItem
        };
      }
      if (!assetItem.base) {
        assetItem.base = assetKey;
      }
      assetItem.type = assetKey;
      list.push(assetItem);
    });
  }

  // transform files to scr-dest mapping
  list.forEach(function (asset) {

    var mapping = [];
    var flatName = typeof asset.flatten !== "boolean" ? true : asset.flatten;
    var assetPath = path.posix.join(clientLibPath, asset.base);
    var globOptions = {};
    if (asset.cwd) {
      globOptions.cwd = asset.cwd;
    }

    asset.files.forEach(function (file) {
      var fileItem = file;

      // convert simple syntax to object
      if (_.isString(file)) {
        fileItem = {
          src: file
        };
      }

      // no magic pattern -> default behaviour
      if (!glob.hasMagic(fileItem.src)) {

        // determine default dest
        if (!fileItem.dest) {
          fileItem.dest = path.posix.basename(file);
        }

        // generate full path
        fileItem.dest = path.posix.join(assetPath, fileItem.dest);
        mapping.push(fileItem);
      }

      // resolve magic pattern
      else {
        var files = glob.sync(fileItem.src, globOptions);
        var hasCwd = !!globOptions.cwd;
        var dest = fileItem.dest ? path.posix.join(assetPath, fileItem.dest) : assetPath;

        files.forEach(function (resolvedFile) {

          // check 'flatten' option -> strip dir name
          var destFile = flatName ? path.posix.basename(resolvedFile) : resolvedFile;

          var item = {
            src: resolvedFile,
            dest: path.posix.join(dest, destFile)
          };

          // check "cwd" option -> rebuild path, because it was stripped by glob.sync()
          if (hasCwd) {
            item.src = path.posix.join(globOptions.cwd, resolvedFile);
          }

          mapping.push(item);
        });
      }
    });

    asset.files = mapping;
  });

  return list;
}
683052
def QA_SU_save_option_commodity_min(engine, client=DATABASE):
    '''
    
    '''
    engine = select_save_engine(engine)
    engine.QA_SU_save_option_commodity_min(client=client)
918914
def rollback(self, sql=None):
        """"""
        self._transaction = False
        try:
            rollback = self._con.rollback
        except AttributeError:
            return self._con.query(sql or 'rollback')
        else:
            if sql:
                return rollback(sql=sql)
            else:
                return rollback()