Skip to content

Commit

Permalink
Update migrations to SQLAlchemy 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
stchris committed Jun 27, 2023
1 parent 06420dc commit 0e59b41
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions aleph/migrate/versions/4c9e198c5b31_entitysets.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ def upgrade():
bind = op.get_bind()
meta = sa.MetaData()
meta.bind = bind
meta.reflect()
meta.reflect(bind=bind)
diagram_table = meta.tables["diagram"]
entityset_table = meta.tables["entityset"]
item_table = meta.tables["entityset_item"]

q = sa.select([diagram_table])
q = sa.select(diagram_table)
rp = bind.execute(q)
while True:
diagram = rp.fetchone()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def upgrade():
bind = op.get_bind()
meta = sa.MetaData()
meta.bind = bind
meta.reflect()
meta.reflect(bind)
linkage_table = meta.tables["linkage"]
entityset_table = meta.tables["entityset"]
item_table = meta.tables["entityset_item"]
Expand All @@ -43,7 +43,7 @@ def upgrade():
q = q.values({"judgement": "POSITIVE"})
bind.execute(q)

q = sa.select([linkage_table]).order_by("profile_id")
q = sa.select(linkage_table).order_by("profile_id")
rp = bind.execute(q)

profiles = groupby(
Expand Down
2 changes: 1 addition & 1 deletion aleph/migrate/versions/aa486b9e627e_hard_deletes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
def upgrade():
meta = sa.MetaData()
meta.bind = op.get_bind()
meta.reflect()
meta.reflect(bind=meta.bind)
for table_name in ("alert", "entity", "mapping", "permission"):
table = meta.tables[table_name]
q = sa.delete(table).where(table.c.deleted_at != None) # noqa
Expand Down
6 changes: 3 additions & 3 deletions aleph/migrate/versions/b3959bf8cc66_entity_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ def upgrade():
bind = op.get_bind()
meta = sa.MetaData()
meta.bind = bind
meta.reflect()
meta.reflect(bind=bind)
entity_table = meta.tables["entity"]
collection_table = meta.tables["collection"]
q = sa.select([collection_table])
q = sa.select(collection_table)
crp = bind.execute(q)
for collection in crp.fetchall():
ns = Namespace(collection.foreign_id)
q = sa.select([entity_table])
q = sa.select(entity_table)
q = q.where(entity_table.c.collection_id == collection.id)
erp = bind.execute(q)
while True:
Expand Down

0 comments on commit 0e59b41

Please sign in to comment.