feat(db): add nullable notes column to entry and month_entry

Free-text annotation up to 1024 chars. Nullable so existing rows need
no backfill; an empty or whitespace-only input will be normalised to
NULL in the service layer. Alembic batch_alter_table handles the
SQLite table rebuild automatically.

Refs #13

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
archeious 2026-04-17 12:51:22 -06:00
parent 1eecfc3ae8
commit 4d40843e24
2 changed files with 44 additions and 0 deletions

View file

@ -0,0 +1,42 @@
"""add notes column to entry and month_entry
Revision ID: ec804bdf366d
Revises: 03ebe3c07262
Create Date: 2026-04-17 12:47:41.533978
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = 'ec804bdf366d'
down_revision: Union[str, Sequence[str], None] = '03ebe3c07262'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('entry', schema=None) as batch_op:
batch_op.add_column(sa.Column('notes', sa.String(length=1024), nullable=True))
with op.batch_alter_table('month_entry', schema=None) as batch_op:
batch_op.add_column(sa.Column('notes', sa.String(length=1024), nullable=True))
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('month_entry', schema=None) as batch_op:
batch_op.drop_column('notes')
with op.batch_alter_table('entry', schema=None) as batch_op:
batch_op.drop_column('notes')
# ### end Alembic commands ###

View file

@ -51,6 +51,7 @@ class Entry(Base):
) )
name: Mapped[str] = mapped_column(String(128), nullable=False) name: Mapped[str] = mapped_column(String(128), nullable=False)
amount: Mapped[Decimal] = mapped_column(Numeric(10, 2), nullable=False) amount: Mapped[Decimal] = mapped_column(Numeric(10, 2), nullable=False)
notes: Mapped[str | None] = mapped_column(String(1024), nullable=True)
created_at: Mapped[datetime] = mapped_column( created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), server_default=func.now(), nullable=False DateTime(timezone=True), server_default=func.now(), nullable=False
) )
@ -117,6 +118,7 @@ class MonthEntry(Base):
Numeric(10, 2), nullable=False, default=Decimal("0.00"), Numeric(10, 2), nullable=False, default=Decimal("0.00"),
server_default="0.00", server_default="0.00",
) )
notes: Mapped[str | None] = mapped_column(String(1024), nullable=True)
origin_name: Mapped[str | None] = mapped_column(String(128), nullable=True) origin_name: Mapped[str | None] = mapped_column(String(128), nullable=True)
origin_planned: Mapped[Decimal | None] = mapped_column( origin_planned: Mapped[Decimal | None] = mapped_column(
Numeric(10, 2), nullable=True Numeric(10, 2), nullable=True