Skip to content

Commit 8dc7d6d

Browse files
authored
Fixing migrations (#16)
* Fixing migrations * Update 6a486347af93_order.py
1 parent a6c8d8f commit 8dc7d6d

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

migrations/versions/6a486347af93_order.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ def upgrade():
3535
op.alter_column('button', 'category_id', existing_type=sa.INTEGER(), nullable=False)
3636
op.alter_column('button', 'icon', existing_type=sa.VARCHAR(), nullable=False)
3737
op.add_column('category', sa.Column('order', sa.Integer(), nullable=True))
38-
conn = op.get_bind()
3938
res = conn.execute(sa.text("select id from category")).fetchall()
4039
for i in range(0, len(res)):
41-
conn.execute(sa.text(f'select order from category where category.id={res[i]} update category set order = {i+1}'))
40+
conn.execute(sa.text(f"""UPDATE "category"
41+
SET "order"={i + 1}
42+
WHERE id={res[i][0]}"""))
4243
op.alter_column('category', 'order', nullable=False)
4344
op.alter_column('category', 'name', existing_type=sa.VARCHAR(), nullable=False)
4445
op.alter_column('category', 'type', existing_type=sa.VARCHAR(), nullable=False)

0 commit comments

Comments
 (0)