~sircmpwn/dispatch.sr.ht

ref: 3a56828e48216d66de8fa71fc4db5270e009eb75 dispatch.sr.ht/dispatchsrht/alembic/versions/101d96a6baaf_add_gitlab_tables.py -rw-r--r-- 2.5 KiB View raw
3a56828eDrew DeVault Support running builds.sr.ht CI for GitLab commits 7 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""Add gitlab tables

Revision ID: 101d96a6baaf
Revises: 986fd25d5184
Create Date: 2019-10-23 12:40:05.563827

"""

# revision identifiers, used by Alembic.
revision = '101d96a6baaf'
down_revision = '986fd25d5184'

from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils as sau


def upgrade():
    op.create_table('gitlab_authorization',
        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('upstream', sa.Unicode, nullable=False),
        sa.Column('oauth_token', sa.Unicode(512), nullable=False))

    op.create_table('gitlab_commit_to_build',
        sa.Column('id', sau.UUIDType, 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", ondelete="CASCADE")),
        sa.Column('task_id', sa.Integer,
            sa.ForeignKey("task.id", ondelete="CASCADE")),
        sa.Column('repo_name', sa.Unicode, nullable=False),
        sa.Column('repo_id', sa.Integer, nullable=False),
        sa.Column('web_url', sa.Unicode, nullable=False),
        sa.Column('gitlab_webhook_id', sa.Integer, nullable=False),
        sa.Column('secrets', sa.Boolean, nullable=False, server_default='t'),
        sa.Column('upstream', sa.Unicode, nullable=False))

    op.create_table('gitlab_mr_to_build',
        sa.Column('id', sau.UUIDType, 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", ondelete="CASCADE")),
        sa.Column('task_id', sa.Integer,
                sa.ForeignKey("task.id", ondelete="CASCADE")),
        sa.Column('repo_name', sa.Unicode(1024), nullable=False),
        sa.Column('repo_id', sa.Integer, nullable=False),
        sa.Column('web_url', sa.Unicode, nullable=False),
        sa.Column('gitlab_webhook_id', sa.Integer, nullable=False),
        sa.Column('upstream', sa.Unicode, nullable=False),
        sa.Column('private', sa.Boolean, nullable=False, server_default='f'),
        sa.Column('secrets', sa.Boolean, nullable=False, server_default='f'))

def downgrade():
    op.drop_table('gitlab_authorization')
    op.drop_table('gitlab_commit_to_build')
    op.drop_table('gitlab_mr_to_build')