Enact migration script from one version of pgpm to another (newer)
        :param cur:
        :param migrate_or_leave: True if migrating, False if exiting
        :return:

def _migrate_pgpm_version(self, cur, version_pgpm_db, version_pgpm_script,  migrate_or_leave):
        """
        Enact migration script from one version of pgpm to another (newer)
        :param cur:
        :param migrate_or_leave: True if migrating, False if exiting
        :return:
        """
        migrations_file_re = r'^(.*)-(.*).tmpl.sql$'
        migration_files_list = sorted(pkg_resources.resource_listdir(self._main_module_name, 'lib/db_scripts/migrations/'),
                                      key=lambda filename: distutils.version.StrictVersion(filename.split('-')[0]))
        for file_info in migration_files_list:
            versions_list = re.compile(migrations_file_re, flags=re.IGNORECASE).findall(file_info)
            version_a = distutils.version.StrictVersion(versions_list[0][0])
            version_b = distutils.version.StrictVersion(versions_list[0][1])
            if version_pgpm_script >= version_a and version_b > version_pgpm_db:
                # Python 3.x doesn't have format for byte strings so we have to convert
                migration_script = pkg_resources.resource_string(self._main_module_name, 'lib/db_scripts/migrations/{0}'.format(file_info))\
                    .decode('utf-8').format(schema_name=self._pgpm_schema_name)
                if migrate_or_leave:
                    self._logger.debug('Running version upgrade script {0}'.format(file_info))
                    self._logger.debug(migration_script)
                    cur.execute(migration_script)
                    self._conn.commit()
                    pgpm.lib.utils.db.SqlScriptsHelper.set_search_path(cur, self._pgpm_schema_name)
                    cur.callproc('_add_migration_info', [versions_list[0][0], versions_list[0][1]])
                    self._conn.commit()
                    self._logger.debug('Successfully finished running version upgrade script {0}'.format(file_info))

        if not migrate_or_leave:
            self._logger.error('{0} schema version is outdated. Please run pgpm install --upgrade first.'
                               .format(self._pgpm_schema_name))
            self._conn.close()
            sys.exit(1)