Ejemplo n.º 1
0
def upgrade():
    op.add_column('issues', sa.Column('status_date', sa.DateTime(), nullable=True))

    issues = get_table(op.get_bind(), 'issues')
    op.execute(issues.update().values(status_date = datetime.now()))

    op.alter_column('issues', 'status_date', nullable=False)
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('issues', sa.Column('status', sa.String(), nullable=True))

    issues = get_table(op.get_bind(), 'issues')
    op.execute(issues.update().values(status='todo'))

    op.alter_column('issues', 'status', nullable=False)
Ejemplo n.º 3
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        'issues',
        sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'issues', type_='foreignkey')
    op.drop_constraint(None, 'issues', type_='foreignkey')
    op.create_foreign_key('issues_user_id_fkey',
                          'issues',
                          'users', ['user_id'], ['id'],
                          ondelete='CASCADE')

    issues = get_table(op.get_bind(), 'issues')
    op.execute(issues.update().values(user_id=issues.c.reporter_id))

    op.drop_column('issues', 'reporter_id')
    op.drop_column('issues', 'assignee_id')
    op.alter_column('issues', 'user_id', nullable=False)
Ejemplo n.º 4
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('issues',
                  sa.Column('assignee_id', sa.Integer(), nullable=True))
    op.add_column('issues',
                  sa.Column('reporter_id', sa.Integer(), nullable=True))
    op.drop_constraint('issues_user_id_fkey', 'issues', type_='foreignkey')
    op.create_foreign_key(None,
                          'issues',
                          'users', ['assignee_id'], ['id'],
                          ondelete='SET NULL')
    op.create_foreign_key(None,
                          'issues',
                          'users', ['reporter_id'], ['id'],
                          ondelete='CASCADE')

    issues = get_table(op.get_bind(), 'issues')
    op.execute(issues.update().values(reporter_id=issues.c.user_id))
    op.execute(issues.update().values(assignee_id=issues.c.user_id).where(
        issues.c.status.in_(['done', 'in progress'])))

    op.alter_column('issues', 'reporter_id', nullable=False)
    op.drop_column('issues', 'user_id')
Ejemplo n.º 5
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('issues', sa.Column('rank', sa.Integer(), nullable=True))

    issues = get_table(op.get_bind(), 'issues')
    op.execute(issues.update().values(rank=issues.c.id))