This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/data/migrations/versions/3b668be15dc0_add_stars.py
Jimmy Zelinskie eb956e5b7d initial work on adding models for starring repos.
I'm sick of using `git stash`.
2014-12-02 17:31:21 -08:00

42 lines
1.6 KiB
Python

"""add stars
Revision ID: 3b668be15dc0
Revises: 204abf14783d
Create Date: 2014-11-14 14:11:18.687340
"""
# revision identifiers, used by Alembic.
revision = '3b668be15dc0'
down_revision = '204abf14783d'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
def upgrade(tables):
### commands auto generated by Alembic - please adjust! ###
op.create_table('star',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('repository_id', sa.Integer(), nullable=False),
sa.Column('created', sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], name=op.f('fk_star_repository_id_repository')),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('fk_star_user_id_user')),
sa.PrimaryKeyConstraint('id', name=op.f('pk_star'))
)
op.create_index('star_repository_id', 'star', ['repository_id'], unique=False)
op.create_index('star_user_id', 'star', ['user_id'], unique=False)
op.create_index('star_user_id_repository_id', 'star', ['user_id', 'repository_id'], unique=True)
### end Alembic commands ###
def downgrade(tables):
### commands auto generated by Alembic - please adjust! ###
op.drop_constraint('fk_star_repository_id_repository', 'star', type_='foreignkey')
op.drop_constraint('fk_star_user_id_user', 'star', type_='foreignkey')
op.drop_index('star_user_id_repository_id', table_name='star')
op.drop_index('star_user_id', table_name='star')
op.drop_index('star_repository_id', table_name='star')
op.drop_table('star')
### end Alembic commands ###