|
Pierre-Yves Chibon |
8715b5 |
"""commit flag
|
|
Pierre-Yves Chibon |
8715b5 |
|
|
Pierre-Yves Chibon |
8715b5 |
Revision ID: 2b626a16542e
|
|
Pierre-Yves Chibon |
8715b5 |
Revises: 2fb229dac744
|
|
Pierre-Yves Chibon |
8715b5 |
Create Date: 2017-11-15 10:06:55.088665
|
|
Pierre-Yves Chibon |
8715b5 |
|
|
Pierre-Yves Chibon |
8715b5 |
"""
|
|
Pierre-Yves Chibon |
8715b5 |
|
|
Pierre-Yves Chibon |
8715b5 |
import datetime
|
|
Pierre-Yves Chibon |
8715b5 |
|
|
Pierre-Yves Chibon |
8715b5 |
from alembic import op
|
|
Pierre-Yves Chibon |
8715b5 |
import sqlalchemy as sa
|
|
Pierre-Yves Chibon |
8715b5 |
|
|
Pierre-Yves Chibon |
8715b5 |
# revision identifiers, used by Alembic.
|
|
Pierre-Yves Chibon |
8715b5 |
revision = '2b626a16542e'
|
|
Pierre-Yves Chibon |
8715b5 |
down_revision = '2fb229dac744'
|
|
Pierre-Yves Chibon |
8715b5 |
|
|
Pierre-Yves Chibon |
8715b5 |
|
|
Pierre-Yves Chibon |
8715b5 |
def upgrade():
|
|
Pierre-Yves Chibon |
8715b5 |
''' Create the commit_flags table. '''
|
|
Pierre-Yves Chibon |
8715b5 |
|
|
Pierre-Yves Chibon |
8715b5 |
op.create_table(
|
|
Pierre-Yves Chibon |
8715b5 |
'commit_flags',
|
|
Pierre-Yves Chibon |
8715b5 |
sa.Column('id', sa.Integer, primary_key=True),
|
|
Pierre-Yves Chibon |
8715b5 |
sa.Column('uid', sa.String(32), unique=True, nullable=False),
|
|
Pierre-Yves Chibon |
8715b5 |
sa.Column('commit_hash', sa.String(40), index=True, nullable=False),
|
|
Pierre-Yves Chibon |
8715b5 |
sa.Column(
|
|
Pierre-Yves Chibon |
8715b5 |
'token_id', sa.String(64),
|
|
Pierre-Yves Chibon |
8715b5 |
sa.ForeignKey('tokens.id'), nullable=False),
|
|
Pierre-Yves Chibon |
8715b5 |
sa.Column(
|
|
Pierre-Yves Chibon |
8715b5 |
'project_id',
|
|
Pierre-Yves Chibon |
8715b5 |
sa.Integer,
|
|
Pierre-Yves Chibon |
8715b5 |
sa.ForeignKey(
|
|
Pierre-Yves Chibon |
8715b5 |
'projects.id', onupdate='CASCADE', ondelete='CASCADE',
|
|
Pierre-Yves Chibon |
8715b5 |
),
|
|
Pierre-Yves Chibon |
8715b5 |
nullable=False, index=True),
|
|
Pierre-Yves Chibon |
8715b5 |
sa.Column(
|
|
Pierre-Yves Chibon |
8715b5 |
'user_id', sa.Integer,
|
|
Pierre-Yves Chibon |
8715b5 |
sa.ForeignKey('users.id', onupdate='CASCADE'),
|
|
Pierre-Yves Chibon |
8715b5 |
nullable=False, index=True),
|
|
Pierre-Yves Chibon |
abcbf7 |
sa.Column('status', sa.String(32), nullable=False),
|
|
Pierre-Yves Chibon |
8715b5 |
sa.Column('username', sa.Text(), nullable=False),
|
|
Pierre-Yves Chibon |
abcbf7 |
sa.Column('percent', sa.Integer(), nullable=True),
|
|
Pierre-Yves Chibon |
8715b5 |
sa.Column('comment', sa.Text(), nullable=False),
|
|
Pierre-Yves Chibon |
8715b5 |
sa.Column('url', sa.Text(), nullable=False),
|
|
Pierre-Yves Chibon |
8715b5 |
sa.Column(
|
|
Pierre-Yves Chibon |
8715b5 |
'date_created', sa.DateTime, nullable=False,
|
|
Pierre-Yves Chibon |
8715b5 |
default=datetime.datetime.utcnow),
|
|
Pierre-Yves Chibon |
8715b5 |
)
|
|
Pierre-Yves Chibon |
8715b5 |
|
|
Pierre-Yves Chibon |
dc4c19 |
op.create_unique_constraint(
|
|
Pierre-Yves Chibon |
dc4c19 |
"commit_flags_uid_commit_hash_key",
|
|
Pierre-Yves Chibon |
dc4c19 |
'commit_flags',
|
|
Pierre-Yves Chibon |
dc4c19 |
["uid", "commit_hash"]
|
|
Pierre-Yves Chibon |
dc4c19 |
)
|
|
Pierre-Yves Chibon |
dc4c19 |
|
|
Pierre-Yves Chibon |
8715b5 |
|
|
Pierre-Yves Chibon |
8715b5 |
def downgrade():
|
|
Pierre-Yves Chibon |
8715b5 |
''' Drop the commit_flags table. '''
|
|
Pierre-Yves Chibon |
8715b5 |
|
|
Pierre-Yves Chibon |
8715b5 |
op.drop_table('commit_flags')
|