This repository has been archived on 2026-02-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
shared/alembic/old_versions/20251107_123000_widen_alembic_version.py
giles 668d9c7df8 feat: initial shared library extraction
Contains shared infrastructure for all coop services:
- shared/ (factory, urls, user_loader, context, internal_api, jinja_setup)
- models/ (User, Order, Calendar, Ticket, Product, Ghost CMS)
- db/ (SQLAlchemy async session, base)
- suma_browser/app/ (csrf, middleware, errors, authz, redis_cacher, payments, filters, utils)
- suma_browser/templates/ (shared base layouts, macros, error pages)
- static/ (CSS, JS, fonts, images)
- alembic/ (database migrations)
- config/ (app-config.yaml)
- editor/ (Lexical editor Node.js build)
- requirements.txt

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 23:11:36 +00:00

45 lines
1.4 KiB
Python

"""widen alembic_version.version_num to 255
Revision ID: 20251107_123000_widen_alembic_version
Revises: 20251107_121500_labels_stickers
Create Date: 2025-11-07T12:30:00.000000
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "20251107_123000_widen_alembic_version"
down_revision = "20251107_121500_labels_stickers"
branch_labels = None
depends_on = None
def upgrade() -> None:
"""Increase the size of alembic_version.version_num to 255."""
# Most projects use Postgres; this raw SQL is explicit and works reliably.
# Widening requires no USING clause on Postgres, but we'll be explicit for clarity.
op.execute(
"ALTER TABLE alembic_version "
"ALTER COLUMN version_num TYPE VARCHAR(255)"
)
# If you need cross-dialect support later, you could add dialect checks
# and use batch_alter_table for SQLite. For your Postgres setup, this is sufficient.
def downgrade() -> None:
"""Shrink alembic_version.version_num back to 32.
On Postgres, shrinking can fail if any row exceeds 32 chars.
We proactively truncate to 32 to guarantee a clean downgrade.
"""
# Truncate any too-long values to fit back into VARCHAR(32)
op.execute(
"UPDATE alembic_version SET version_num = LEFT(version_num, 32)"
)
op.execute(
"ALTER TABLE alembic_version "
"ALTER COLUMN version_num TYPE VARCHAR(32)"
)