def upgrade():
conn = op.get_bind()
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('projects', sa.Column('task_creation_mode', sa.Integer(), nullable=True))
op.create_index('idx_geometry', 'projects', ['geometry'], unique=False, postgresql_using='gist')
op.add_column('tasks', sa.Column('extra_properties', sa.Unicode(), nullable=True))
for project in conn.execute(projects.select()):
zooms = conn.execute(
sa.sql.expression.select([tasks.c.zoom]).distinct(tasks.c.zoom)
.where(tasks.c.project_id == project.id))
zooms = zooms.fetchall()
if len(zooms) == 1 and zooms[0] == (None,):
op.execute(
projects.update().where(projects.c.id == project.id)
.values(task_creation_mode=1))
# ### end Alembic commands ###
评论列表
文章目录