"""add stars Revision ID: 2088f2b81010 Revises: 1c5b738283a5 Create Date: 2014-12-02 17:45:00.707498 """ # revision identifiers, used by Alembic. revision = '2088f2b81010' down_revision = '707d5191eda' from alembic import op import sqlalchemy as sa 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')) ) with op.batch_alter_table('star', schema=None) as batch_op: batch_op.create_index('star_repository_id', ['repository_id'], unique=False) batch_op.create_index('star_user_id', ['user_id'], unique=False) batch_op.create_index('star_user_id_repository_id', ['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') with op.batch_alter_table('star', schema=None) as batch_op: batch_op.drop_index('star_user_id_repository_id') batch_op.drop_index('star_user_id') batch_op.drop_index('star_repository_id') op.drop_table('star')