simpletodoapplication-hf66ut/migrations/versions/004_add_subtasks_and_reminders.py
Automated Action 660c28b96c Add subtasks and reminders functionality
- Added subtask model with CRUD operations
- Added reminder functionality to Todo model
- Added endpoints for managing subtasks and reminders
- Created new migration for subtasks and reminders
- Updated documentation

generated with BackendIM... (backend.im)
2025-05-12 23:37:35 +00:00

46 lines
1.4 KiB
Python

"""Add subtasks and reminders
Revision ID: 004
Revises: 003_add_tags_table_and_associations
Create Date: 2025-05-12
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '004'
down_revision = '003_add_tags_table_and_associations'
branch_labels = None
depends_on = None
def upgrade():
# Add remind_at column to todos table
op.add_column('todos', sa.Column('remind_at', sa.DateTime(timezone=True), nullable=True))
# Create subtasks table
op.create_table(
'subtasks',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('title', sa.String(length=100), nullable=False),
sa.Column('completed', sa.Boolean(), default=False),
sa.Column('todo_id', sa.Integer(), nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.func.now()),
sa.Column('updated_at', sa.DateTime(timezone=True), onupdate=sa.func.now()),
sa.ForeignKeyConstraint(['todo_id'], ['todos.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id')
)
# Add index on todo_id for faster lookups
op.create_index(op.f('ix_subtasks_todo_id'), 'subtasks', ['todo_id'], unique=False)
def downgrade():
# Drop subtasks table
op.drop_index(op.f('ix_subtasks_todo_id'), table_name='subtasks')
op.drop_table('subtasks')
# Remove remind_at column from todos table
op.drop_column('todos', 'remind_at')