opencompletion.com/migrations/versions/190d5ef26e20_add_token_count_to_message.py
Russell Ballestrini 1b44c2d66b Integrate comprehensive testing framework with Makefile
- Added unit tests for YAML loading and parsing functionality
- Created integration tests for multiple activity files validation
- Implemented functional tests for complete activity workflows
- Added battleship pre_script functionality tests
- Integrated all test types into comprehensive Makefile
- Fixed CLI validator test with proper failing fixture
- Applied black formatting to all Python files
- Removed problematic hardcoded targets from Makefile
- Added proper venv dependency management

Test coverage includes:
- Unit: YAML loading, validator functionality
- Integration: Cross-file validation, metadata operations
- Functional: End-to-end activity flows, pre_script execution
- All 30 activity files validated and tested
2025-08-10 19:38:50 -04:00

44 lines
1.1 KiB
Python

"""Add token_count to Message
Revision ID: 190d5ef26e20
Revises: a9e886c56482
Create Date: 2023-12-07 08:55:50.378439
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.orm import Session
# revision identifiers, used by Alembic.
revision = "190d5ef26e20"
down_revision = "a9e886c56482"
branch_labels = None
depends_on = None
from app import Message
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("message", schema=None) as batch_op:
batch_op.add_column(sa.Column("token_count", sa.Integer(), nullable=True))
# Use this binding to connect to the database
bind = op.get_bind()
session = Session(bind=bind)
# Assuming the content column is not nullable and always has a value
messages = session.query(Message).all()
for message in messages:
message.count_tokens()
session.add(message)
session.commit()
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("message", schema=None) as batch_op:
batch_op.drop_column("token_count")