Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! fixup! fixup! clean up orphaned blobs
Browse files Browse the repository at this point in the history
  • Loading branch information
jvansanten committed Feb 16, 2024
1 parent b3f6d66 commit 8c8fb7c
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions migrations/02_add_archive_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,22 @@
)
).returning(Archive.c.uri)
with connection.begin() as transaction:
for row in connection.execute(statement).fetchall():
for row in connection.execute(
Archive.delete(
sa.and_(
Archive.c.refcount == 0,
Archive.c.avro_archive_id
< (
sa.select([Alert.c.avro_archive_id - 100])
.order_by(Alert.c.alert_id.desc())
.limit(1)
),
)
).returning(Archive.c.uri)
).fetchall():
key = get_key_for_url(bucket, row["uri"])
print(f"delete {key}")
# bucket.Object(key).delete()
transaction.rollback()
bucket.Object(key).delete()
transaction.commit()
# print(
# statement.compile(
# dialect=engine.dialect, compile_kwargs={"literal_binds": True}
Expand Down

0 comments on commit 8c8fb7c

Please sign in to comment.