This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-release.git


The following commit(s) were added to refs/heads/main by this push:
     new ec2dcd6  Fix a problem with Alembic migration
ec2dcd6 is described below

commit ec2dcd635fdd2003274e785464557cd247d44f36
Author: Sean B. Palmer <[email protected]>
AuthorDate: Tue May 13 16:47:35 2025 +0100

    Fix a problem with Alembic migration
---
 atr/blueprints/admin/admin.py                   |  4 +--
 migrations/versions/0005_2025.05.13_d94f16f6.py | 42 +++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/atr/blueprints/admin/admin.py b/atr/blueprints/admin/admin.py
index 35f6566..0e74a41 100644
--- a/atr/blueprints/admin/admin.py
+++ b/atr/blueprints/admin/admin.py
@@ -129,10 +129,10 @@ async def admin_delete_release() -> str | 
response.Response:
                     _LOGGER.error("Error deleting release %s: %s", 
release_name, e)
                     fail_count += 1
                     error_messages.append(f"{release_name}: {e}")
-                except Exception:
+                except Exception as e:
                     _LOGGER.exception("Unexpected error deleting release %s:", 
release_name)
                     fail_count += 1
-                    error_messages.append(f"{release_name}: Unexpected error")
+                    error_messages.append(f"{release_name}: Unexpected error 
({e})")
 
             if success_count > 0:
                 await quart.flash(f"Successfully deleted {success_count} 
release(s).", "success")
diff --git a/migrations/versions/0005_2025.05.13_d94f16f6.py 
b/migrations/versions/0005_2025.05.13_d94f16f6.py
new file mode 100644
index 0000000..aef4857
--- /dev/null
+++ b/migrations/versions/0005_2025.05.13_d94f16f6.py
@@ -0,0 +1,42 @@
+"""Delete tasks with obsolete ZIPFORMAT types
+
+Revision ID: 0005_2025.05.13_d94f16f6
+Revises: 0004_2025.05.13_657bf05b
+Create Date: 2025-05-13 15:42:21.333191+00:00
+"""
+
+from collections.abc import Sequence
+
+import sqlalchemy as sa
+from alembic import op
+
+# Revision identifiers, used by Alembic
+revision: str = "0005_2025.05.13_d94f16f6"
+down_revision: str | None = "0004_2025.05.13_657bf05b"
+branch_labels: str | Sequence[str] | None = None
+depends_on: str | Sequence[str] | None = None
+
+
+def upgrade() -> None:
+    """Delete tasks with obsolete ZIPFORMAT_LICENSE_FILES and 
ZIPFORMAT_LICENSE_HEADERS types."""
+    bind = op.get_bind()
+    result = bind.execute(
+        sa.text(
+            "SELECT 1 FROM task WHERE task_type IN ('ZIPFORMAT_LICENSE_FILES', 
'ZIPFORMAT_LICENSE_HEADERS') LIMIT 1"
+        )
+    ).scalar_one_or_none()
+
+    if result is not None:
+        op.execute("DELETE FROM task WHERE task_type IN 
('ZIPFORMAT_LICENSE_FILES', 'ZIPFORMAT_LICENSE_HEADERS')")
+
+
+def downgrade() -> None:
+    """
+    Downgrade for this migration.
+
+    Since the upgrade deletes data that corresponds to obsolete enum types,
+    a downgrade doesn't have a straightforward way to restore these tasks
+    without knowing their original context or reintroducing obsolete types.
+    Therefore, this downgrade is a noop.
+    """
+    pass


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to