
- Add missing migration files for tags (005) and subtasks (006) - Update model imports to include Tag and todo_tags association - Integrate tags router into API endpoints - Fix migration sequence and dependencies - Format all code with Ruff - Complete integration of all organization features
44 lines
1.0 KiB
Python
44 lines
1.0 KiB
Python
"""Add parent_id for subtasks functionality
|
|
|
|
Revision ID: 006
|
|
Revises: 005
|
|
Create Date: 2025-06-18 17:00:00.000000
|
|
|
|
"""
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = "006"
|
|
down_revision = "005"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# Add parent_id column to todos table
|
|
op.add_column(
|
|
"todos",
|
|
sa.Column("parent_id", sa.Integer(), nullable=True),
|
|
)
|
|
|
|
# Add foreign key constraint for self-referential relationship
|
|
op.create_foreign_key(
|
|
"fk_todos_parent_id",
|
|
"todos",
|
|
"todos",
|
|
["parent_id"],
|
|
["id"],
|
|
ondelete="CASCADE",
|
|
)
|
|
|
|
# Add index for better performance
|
|
op.create_index(op.f("ix_todos_parent_id"), "todos", ["parent_id"], unique=False)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index(op.f("ix_todos_parent_id"), table_name="todos")
|
|
op.drop_constraint("fk_todos_parent_id", "todos", type_="foreignkey")
|
|
op.drop_column("todos", "parent_id")
|