"""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): 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) def downgrade(tables): 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')