Example #1
0
    def delete_project(self, project, keep_db):
        index = GeneralHelper.get_index_on_dict_value(collection=self.projects,
                                                      key='ref',
                                                      value=project.ref_name)
        self.projects.pop(index)
        DirectusController.delete_config(path=self.path,
                                         pj_name=project.ref_name)
        if not keep_db:
            env_db = db(self.db_user, self.db_pw)
            env_db.drop_db(project.ref_name)

        self.write()
Example #2
0
    def add_project(self, project, migration_file):
        env_db = db(self.db_user, self.db_pw)
        env_db.add_db(project.ref_name)
        DirectusController.install_config(path=self.path,
                                          db_name=project.ref_name,
                                          db_user=self.db_user,
                                          db_pw=self.db_pw,
                                          pj_name=project.ref_name)
        DirectusController.install_database(path=self.path,
                                            pj_name=project.ref_name)
        if migration_file:
            Migration(username=self.db_user,
                      password=self.db_pw,
                      database=project.ref_name,
                      name=project.ref_name).migrate(migration_file)

        DirectusController.init_user(path=self.path, pj_name=project.ref_name)
        self.write_new_projects(project=project)
Example #3
0
 def validate_db_name_unique(username, password, name):
     env_db = db(username=username, password=password)
     env_db.connect()
     return env_db.check_name_unique(name)
Example #4
0
 def validate_db_connection(username, password):
     return db(username=username, password=password).connect()
Example #5
0
 def list_dbs(self):
     db_env = db(username=self.db_user, password=self.db_pw)
     return list(map(lambda d: d[0], db_env.get_db_databases()))