def check_repository_has_patches(sess, repository_name, patch_names): not_applied = [] for patch_name in patch_names: if not AppliedPatch.is_applied(sess, repository_name, patch_name): not_applied.append(patch_name) if len(not_applied) > 0: raise SqlMigrationException('The repository has an outdated schema ' 'state and misses the patches %s' % (not_applied))
def applied_patches(self): db_patches = AppliedPatch.get_all(self.sess, self.repo_name) patches = [] for dbpatch in db_patches: if dbpatch.patch_name in self.patch_repo.patches: patches.append(self.patch_repo.patches[dbpatch.patch_name]) else: patches.append(Patch(dbpatch.patch_name)) return patches