diff --git a/server/migrations/community/e3a7f2b1c94d_add_upload_last_ping.py b/server/migrations/community/e3a7f2b1c94d_add_upload_last_ping.py deleted file mode 100644 index d53d4440..00000000 --- a/server/migrations/community/e3a7f2b1c94d_add_upload_last_ping.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Add last_ping to upload - -Revision ID: e3a7f2b1c94d -Revises: e3f1a9b2c4d6 -Create Date: 2026-04-14 00:00:00.000000 - -""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = "e3a7f2b1c94d" -down_revision = "e3f1a9b2c4d6" -branch_labels = None -depends_on = None - - -def upgrade(): - op.add_column("upload", sa.Column("last_ping", sa.DateTime(), nullable=True)) - # backfill existing rows before adding NOT NULL constraint - op.execute("UPDATE upload SET last_ping = NOW() WHERE last_ping IS NULL") - op.alter_column("upload", "last_ping", nullable=False) - - -def downgrade(): - # drop the column but required lockfiles will be missing - make sure all uploads are gone - op.drop_column("upload", "last_ping") diff --git a/server/migrations/community/f1d9e4a7b823_add_upload_transaction_id.py b/server/migrations/community/f1d9e4a7b823_update_upload_table_for_concurrency.py similarity index 60% rename from server/migrations/community/f1d9e4a7b823_add_upload_transaction_id.py rename to server/migrations/community/f1d9e4a7b823_update_upload_table_for_concurrency.py index d3797b8b..c99f26df 100644 --- a/server/migrations/community/f1d9e4a7b823_add_upload_transaction_id.py +++ b/server/migrations/community/f1d9e4a7b823_update_upload_table_for_concurrency.py @@ -1,7 +1,7 @@ -"""Add transaction_id to upload +"""Add transaction_id and last_ping columns to upload Revision ID: f1d9e4a7b823 -Revises: e3a7f2b1c94d +Revises: e3f1a9b2c4d6 Create Date: 2026-04-14 00:00:00.000000 """ @@ -13,7 +13,7 @@ # revision identifiers, used by Alembic. revision = "f1d9e4a7b823" -down_revision = "e3a7f2b1c94d" +down_revision = "e3f1a9b2c4d6" branch_labels = None depends_on = None @@ -22,9 +22,17 @@ def upgrade(): op.add_column( "upload", sa.Column("transaction_id", UUID(as_uuid=True), nullable=True) ) + op.add_column("upload", sa.Column("last_ping", sa.DateTime(), nullable=True)) + # backfill existing rows before adding NOT NULL constraint - op.execute("UPDATE upload SET transaction_id = id WHERE transaction_id IS NULL") + op.execute( + "UPDATE upload SET transaction_id = id::uuid WHERE transaction_id IS NULL;" + ) + op.execute("UPDATE upload SET last_ping = NOW() WHERE last_ping IS NULL;") + op.alter_column("upload", "transaction_id", nullable=False) + op.alter_column("upload", "last_ping", nullable=False) + op.create_index( op.f("ix_upload_transaction_id"), "upload", ["transaction_id"], unique=True ) @@ -32,5 +40,6 @@ def upgrade(): def downgrade(): op.drop_index(op.f("ix_upload_transaction_id"), table_name="upload") - # column is dropped but there could be orphan transaction folders, make sure upload table is empty + # column is dropped but there could be orphan transaction folders and required lockfiles will be missing, make sure upload table is empty op.drop_column("upload", "transaction_id") + op.drop_column("upload", "last_ping")