Make grids.side_length not nullable

The ORM always defined `Grid.side_length` with `nullable=False`,
but the migration that created the "grids" table did not; the
live database contains no `NULL`s.
This commit is contained in:
Alexander Hess 2026-12-01 22:02:29 +01:00
commit 2a627072d8
Signed by: alexander
GPG key ID: B46EDB4DFC26805D

View file

@ -0,0 +1,39 @@
"""Make `grids.side_length` not nullable."""
import os
import sqlalchemy as sa
from alembic import op
from velofy import configuration
revision = "6cb552f31132"
down_revision = "81aa304d7a6e"
branch_labels = None
depends_on = None
config = configuration.make_config("testing" if os.getenv("TESTING") else "production")
def upgrade():
"""Upgrade to the next revision."""
op.alter_column(
"grids",
"side_length",
existing_type=sa.SmallInteger(),
nullable=False,
schema=config.CLEAN_SCHEMA,
)
def downgrade():
"""Downgrade to the previous revision."""
op.alter_column(
"grids",
"side_length",
existing_type=sa.SmallInteger(),
nullable=True,
schema=config.CLEAN_SCHEMA,
)