
- Document category management features - Update API endpoints to include categories - Revise project structure to reflect current implementation - Add usage examples for categories and filtering - Remove references to unimplemented features - Update models documentation for Todo and Category
58 lines
1.8 KiB
Python
58 lines
1.8 KiB
Python
"""Add projects table and project_id to todos
|
|
|
|
Revision ID: 004_add_projects
|
|
Revises: 003_add_categories
|
|
Create Date: 2025-06-18 15:00:00.000000
|
|
|
|
"""
|
|
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = "004_add_projects"
|
|
down_revision: Union[str, None] = "003_add_categories"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# Create projects table
|
|
op.create_table(
|
|
"projects",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("name", sa.String(length=200), nullable=False),
|
|
sa.Column("description", sa.String(length=500), nullable=True),
|
|
sa.Column(
|
|
"status", sa.Enum("ACTIVE", "ARCHIVED", name="projectstatus"), nullable=True
|
|
),
|
|
sa.Column(
|
|
"created_at",
|
|
sa.DateTime(timezone=True),
|
|
server_default=sa.text("now()"),
|
|
nullable=True,
|
|
),
|
|
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=True),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index(op.f("ix_projects_id"), "projects", ["id"], unique=False)
|
|
|
|
# Add project_id column to todos table
|
|
op.add_column("todos", sa.Column("project_id", sa.Integer(), nullable=True))
|
|
op.create_foreign_key(
|
|
"fk_todos_project_id", "todos", "projects", ["project_id"], ["id"]
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
# Remove foreign key and project_id column from todos
|
|
op.drop_constraint("fk_todos_project_id", "todos", type_="foreignkey")
|
|
op.drop_column("todos", "project_id")
|
|
|
|
# Drop projects table
|
|
op.drop_index(op.f("ix_projects_id"), table_name="projects")
|
|
op.drop_table("projects")
|