~sircmpwn/meta.sr.ht

ref: 72548bd7545f78670878667674cc7645835a17bd meta.sr.ht/metasrht/alembic/versions/18a2c6a540bc_add_webhook_tables.py -rw-r--r-- 1.6 KiB
72548bd7Drew DeVault API: Updates per core-go auth changes 1 year, 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""Add webhook tables

Revision ID: 18a2c6a540bc
Revises: f1f6b32242fe
Create Date: 2018-12-27 23:54:43.334311

"""

# revision identifiers, used by Alembic.
revision = '18a2c6a540bc'
down_revision = 'f1f6b32242fe'

from alembic import op
import sqlalchemy as sa


def upgrade():
    op.create_table('webhook',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('created', sa.DateTime, nullable=False),
        sa.Column('updated', sa.DateTime, nullable=False),
        sa.Column('user_id', sa.Integer, sa.ForeignKey("user.id")),
        sa.Column('client_id', sa.Integer,
            sa.ForeignKey("oauthclient.id", ondelete="CASCADE")),
        sa.Column('url', sa.Unicode(2048), nullable=False),
        sa.Column('events', sa.Unicode, nullable=False))
    op.create_table('webhook_delivery',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('created', sa.DateTime, nullable=False),
        sa.Column('event', sa.Unicode(256), nullable=False),
        sa.Column('webhook_id', sa.Integer,
            sa.ForeignKey("webhook.id", ondelete="CASCADE"),
            nullable=False),
        sa.Column('url', sa.Unicode(2048), nullable=False),
        sa.Column('payload', sa.Unicode(16384), nullable=False),
        sa.Column('payload_headers', sa.Unicode(16384), nullable=False),
        sa.Column('response', sa.Unicode(16384), nullable=False),
        sa.Column('response_status', sa.Integer, nullable=False),
        sa.Column('response_headers', sa.Unicode(16384), nullable=False))


def downgrade():
    op.drop_table('webhook_delivery')
    op.drop_table('webhook')