diff --git a/data/migrations/versions/47670cbeced_migrate_existing_webhooks_to_.py b/data/migrations/versions/47670cbeced_migrate_existing_webhooks_to_.py index c956250c4..92ce959e1 100644 --- a/data/migrations/versions/47670cbeced_migrate_existing_webhooks_to_.py +++ b/data/migrations/versions/47670cbeced_migrate_existing_webhooks_to_.py @@ -3,6 +3,7 @@ Revision ID: 47670cbeced Revises: 325a4d7c79d9 Create Date: 2014-07-31 13:49:38.332807 +Hand Edited By Joseph Schorr """ @@ -12,11 +13,17 @@ down_revision = '325a4d7c79d9' from alembic import op import sqlalchemy as sa - +from data.database import * +from app import app def upgrade(): - pass + event_id = list(db.execute_sql('Select id From ExternalNotificationEvent Where name="repo_push" Limit 1', ()))[0][0] + method_id = list(db.execute_sql('Select id From ExternalNotificationMethod Where name="webhook" Limit 1', ()))[0][0] + db.execute_sql('Insert Into RepositoryNotification (uuid, repository_id, event_id, method_id, config_json) Select public_id, repository_id, %s, %s, parameters FROM Webhook' % (event_id, method_id)) def downgrade(): - pass + event_id = list(db.execute_sql('Select id From ExternalNotificationEvent Where name="repo_push" Limit 1', ()))[0][0] + method_id = list(db.execute_sql('Select id From ExternalNotificationMethod Where name="webhook" Limit 1', ()))[0][0] + + db.execute_sql('Insert Into Webhook (public_id, repository_id, parameters) Select uuid, repository_id, config_json FROM RepositoryNotification Where event_id=%s And method_id=%s' % (event_id, method_id))