def backfill_plugins():
    r.table('plugins').update({'github_repo_id': ''}).run(r_conn())

    repos = r.table('plugin_github_repos').pluck(
           'repo_id', 'owner', 'repo_name').run(r_conn())

    for i, repo in enumerate(repos):
        if repo['repo_id'] == '':
            continue

        query = r.table('plugins').get_all([repo['owner'], repo['repo_name']],
               index='github_owner_repo')
        plugin = db.util.get_first(query)
        if not plugin:
            continue

        plugin['github_repo_id'] = repo['repo_id']
        db.plugins.insert(plugin)

        print '%s\tBackfilled %s' % (i, plugin['slug'])
Backfill rows of the plugin table with github_repo_id.
dataset/ETHPy150Open vim-awesome/vim-awesome/db/migrations/backfill_github_repo_id.py/backfill_plugins