From 68331859b00071d5f140d260cbb43908be1a9756 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 13 Apr 2017 12:30:44 -0400 Subject: [PATCH] Add backfill for repository search score table --- ...f7_backfill_repositorysearchscore_table.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 data/migrations/versions/c3d4b7ebcdf7_backfill_repositorysearchscore_table.py diff --git a/data/migrations/versions/c3d4b7ebcdf7_backfill_repositorysearchscore_table.py b/data/migrations/versions/c3d4b7ebcdf7_backfill_repositorysearchscore_table.py new file mode 100644 index 000000000..5722c0926 --- /dev/null +++ b/data/migrations/versions/c3d4b7ebcdf7_backfill_repositorysearchscore_table.py @@ -0,0 +1,23 @@ +"""Backfill RepositorySearchScore table + +Revision ID: c3d4b7ebcdf7 +Revises: f30984525c86 +Create Date: 2017-04-13 12:01:59.572775 + +""" + +# revision identifiers, used by Alembic. +revision = 'c3d4b7ebcdf7' +down_revision = 'f30984525c86' + +from alembic import op +import sqlalchemy as sa + +def upgrade(tables): + # Add a 0 entry into the RepositorySearchScore table for each repository that isn't present + conn = op.get_bind() + conn.execute("insert into repositorysearchscore (repository_id, score) SELECT id, 0 FROM " + + "repository WHERE id not in (select repository_id from repositorysearchscore)") + +def downgrade(tables): + pass