Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions server/migrations/community/e3a7f2b1c94d_add_upload_last_ping.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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

"""
Expand All @@ -13,7 +13,7 @@

# revision identifiers, used by Alembic.
revision = "f1d9e4a7b823"
down_revision = "e3a7f2b1c94d"
down_revision = "e3f1a9b2c4d6"
branch_labels = None
depends_on = None

Expand All @@ -22,15 +22,24 @@ 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
)


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")
Loading