~sircmpwn/todo.sr.ht

b15763940b079b7e7a420de59088e6acb2b0386d — Drew DeVault 4 months ago c144bfc 0.61.12
Add core.sr.ht webhook cascades to webhook tables
1 files changed, 108 insertions(+), 0 deletions(-)

A todosrht/alembic/versions/6c714f704591_add_core_sr_ht_cascades_to_tracker_.py
A todosrht/alembic/versions/6c714f704591_add_core_sr_ht_cascades_to_tracker_.py => todosrht/alembic/versions/6c714f704591_add_core_sr_ht_cascades_to_tracker_.py +108 -0
@@ 0,0 1,108 @@
"""Add core.sr.ht cascades to tracker & ticket webhooks

Revision ID: 6c714f704591
Revises: 6742af305c73
Create Date: 2020-09-07 12:42:28.500857

"""

# revision identifiers, used by Alembic.
revision = '6c714f704591'
down_revision = '6742af305c73'

from alembic import op
import sqlalchemy as sa


def upgrade():
    op.drop_constraint(
            constraint_name="tracker_webhook_subscription_token_id_fkey",
            table_name="tracker_webhook_subscription",
            type_="foreignkey")
    op.create_foreign_key(
            constraint_name="tracker_webhook_subscription_token_id_fkey",
            source_table="tracker_webhook_subscription",
            referent_table="oauthtoken",
            local_cols=["token_id"],
            remote_cols=["id"],
            ondelete="CASCADE")
    op.drop_constraint(
            constraint_name="tracker_webhook_subscription_user_id_fkey",
            table_name="tracker_webhook_subscription",
            type_="foreignkey")
    op.create_foreign_key(
            constraint_name="tracker_webhook_subscription_user_id_fkey",
            source_table="tracker_webhook_subscription",
            referent_table="user",
            local_cols=["user_id"],
            remote_cols=["id"],
            ondelete="CASCADE")

    op.drop_constraint(
            constraint_name="ticket_webhook_subscription_token_id_fkey",
            table_name="ticket_webhook_subscription",
            type_="foreignkey")
    op.create_foreign_key(
            constraint_name="ticket_webhook_subscription_token_id_fkey",
            source_table="ticket_webhook_subscription",
            referent_table="oauthtoken",
            local_cols=["token_id"],
            remote_cols=["id"],
            ondelete="CASCADE")
    op.drop_constraint(
            constraint_name="ticket_webhook_subscription_user_id_fkey",
            table_name="ticket_webhook_subscription",
            type_="foreignkey")
    op.create_foreign_key(
            constraint_name="ticket_webhook_subscription_user_id_fkey",
            source_table="ticket_webhook_subscription",
            referent_table="user",
            local_cols=["user_id"],
            remote_cols=["id"],
            ondelete="CASCADE")


def downgrade():
    op.drop_constraint(
            constraint_name="tracker_webhook_subscription_token_id_fkey",
            table_name="tracker_webhook_subscription",
            type_="foreignkey")
    op.create_foreign_key(
            constraint_name="tracker_webhook_subscription_token_id_fkey",
            source_table="tracker_webhook_subscription",
            referent_table="oauthtoken",
            local_cols=["token_id"],
            remote_cols=["id"],
            ondelete="CASCADE")
    op.drop_constraint(
            constraint_name="tracker_webhook_subscription_user_id_fkey",
            table_name="tracker_webhook_subscription",
            type_="foreignkey")
    op.create_foreign_key(
            constraint_name="tracker_webhook_subscription_user_id_fkey",
            source_table="tracker_webhook_subscription",
            referent_table="user",
            local_cols=["user_id"],
            remote_cols=["id"])

    op.drop_constraint(
            constraint_name="ticket_webhook_subscription_token_id_fkey",
            table_name="ticket_webhook_subscription",
            type_="foreignkey")
    op.create_foreign_key(
            constraint_name="ticket_webhook_subscription_token_id_fkey",
            source_table="ticket_webhook_subscription",
            referent_table="oauthtoken",
            local_cols=["token_id"],
            remote_cols=["id"])
    op.drop_constraint(
            constraint_name="ticket_webhook_subscription_user_id_fkey",
            table_name="ticket_webhook_subscription",
            type_="foreignkey")
    op.create_foreign_key(
            constraint_name="ticket_webhook_subscription_user_id_fkey",
            source_table="ticket_webhook_subscription",
            referent_table="user",
            local_cols=["user_id"],
            remote_cols=["id"],
            ondelete="CASCADE")