Skip to content

Commit 38a0f41

Browse files
committed
SQLA 2.0 - Fix connection.execute
execute() in SQL Alchemy 2.x has different behaviour, this patch adapts alembic scripts. See [1]. [1]: https://docs.sqlalchemy.org/en/20/changelog/migration_20.html#execute-method-more-strict-execution-options-are-more-prominent Change-Id: I597eed6f24f13f96f78f6596e16b6edcff989a90
1 parent d544698 commit 38a0f41

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

magnum/db/sqlalchemy/alembic/versions/461d798132c7_change_cluster_to_support_nodegroups.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def upgrade():
6565

6666
connection = op.get_bind()
6767
# Fetching all required info from existing cluster
68-
res = connection.execute(
68+
res = connection.execute(sa.text(
6969
"SELECT "
7070
"cluster.uuid, "
7171
"cluster.name, "
@@ -82,7 +82,7 @@ def upgrade():
8282
"cluster_template.flavor_id, "
8383
"cluster_template.image_id "
8484
"FROM cluster INNER JOIN cluster_template "
85-
"ON cluster.cluster_template_id=cluster_template.uuid"
85+
"ON cluster.cluster_template_id=cluster_template.uuid")
8686
)
8787

8888
results = res.fetchall()

magnum/db/sqlalchemy/alembic/versions/95096e2334ee_add_master_lb_enabled_to_cluster.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ def upgrade():
3333
default=False))
3434
# Populate existing cluster with the cluster template_id
3535
connection = op.get_bind()
36-
connection.execute(
36+
connection.execute(sa.text(
3737
"UPDATE cluster "
3838
"INNER JOIN cluster_template "
3939
"ON cluster_template.uuid=cluster.cluster_template_id "
4040
"SET cluster.master_lb_enabled=cluster_template.master_lb_enabled "
4141
"WHERE cluster_template.uuid=cluster.cluster_template_id and "
42-
"cluster.master_lb_enabled is NULL"
42+
"cluster.master_lb_enabled is NULL")
4343
)

magnum/db/sqlalchemy/alembic/versions/c04e925e65c2_nodegroups_v2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ def upgrade():
4141
# Populate existing nodegroups with the cluster stack_id
4242
connection = op.get_bind()
4343

44-
connection.execute(
44+
connection.execute(sa.text(
4545
"UPDATE nodegroup "
4646
"INNER JOIN cluster ON nodegroup.cluster_id=cluster.uuid "
4747
"SET nodegroup.stack_id=cluster.stack_id, "
4848
"nodegroup.status=cluster.status, nodegroup.version=0 "
49-
"WHERE nodegroup.cluster_id=cluster.uuid"
49+
"WHERE nodegroup.cluster_id=cluster.uuid")
5050
)

0 commit comments

Comments
 (0)