Short IDs become the canonical identifier in URLs (/i/:short_id), MinIO/R2 storage keys, and all API responses. Hash-based deduplication is preserved. Includes two-phase Alembic migration (003 adds nullable column, 004 enforces NOT NULL) with a backfill script to copy storage objects and populate short_id for existing images. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
25 lines
532 B
Python
25 lines
532 B
Python
"""add short_id column to images
|
|
|
|
Revision ID: 003
|
|
Revises: 002
|
|
Create Date: 2026-05-09
|
|
"""
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
revision = "003"
|
|
down_revision = "002"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.add_column("images", sa.Column("short_id", sa.String(8), nullable=True))
|
|
op.create_index("ix_images_short_id", "images", ["short_id"], unique=True)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_images_short_id", table_name="images")
|
|
op.drop_column("images", "short_id")
|