Beispiel #1
0
def setup_dbs(databases, branches_to_ignore=None):
    """Append the current branch name to NAME values of all databases.

    args:
    databases -- django settings DATABASES
    branches_to_ignore -- if the current branch is in branches_to_ignore, the names of databases will not be changed. (default None)
    """
    curr_branch = sh('git rev-parse --abbrev-ref HEAD', False)

    if branches_to_ignore is None:
        branches_to_ignore = ()

    if curr_branch not in branches_to_ignore:
        for db in databases.values():
            db['NAME'] = db_name(db['NAME'], curr_branch)
Beispiel #2
0
 def _perform_branch_db_operation(self, branch_name, method_name):
     for db in self.databases.values():
         engine = get_engine(db, db_name(db['NAME'], branch_name))
         sh(operator.methodcaller(method_name)(engine))