simpletodoapplication-ulpnjc/alembic/versions/6f42ebcf5b2f_add_completion_date.py
Automated Action 34f86c8479 Add task completion tracking with timestamps
- Added completion_date field to Todo model
- Modified CRUD to auto-set completion_date when task is marked complete
- Added completion date stats (last 24h, last week metrics)
- Created Alembic migration for the new field
- Updated API documentation and README

generated with BackendIM... (backend.im)
2025-05-13 04:07:40 +00:00

29 lines
692 B
Python

"""add completion date
Revision ID: 6f42ebcf5b2f
Revises: 5f42ebcf5b2e
Create Date: 2025-05-13
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6f42ebcf5b2f'
down_revision = '5f42ebcf5b2e'
branch_labels = None
depends_on = None
def upgrade():
# Add completion_date column
op.add_column('todos', sa.Column('completion_date', sa.DateTime(timezone=True), nullable=True))
# Set completion_date for already completed todos to their updated_at value
op.execute("UPDATE todos SET completion_date = updated_at WHERE completed = TRUE")
def downgrade():
# Drop column
op.drop_column('todos', 'completion_date')