"""Add subtasks support with parent_id field Revision ID: 003 Revises: 002 Create Date: 2024-01-01 00:00:00.000000 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = "003" down_revision = "002" branch_labels = None depends_on = None def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.add_column( "todos", sa.Column("parent_id", sa.Integer(), nullable=True), ) # Add foreign key constraint op.create_foreign_key( "fk_todos_parent_id", "todos", "todos", ["parent_id"], ["id"], ondelete="CASCADE", ) # ### end Alembic commands ### def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### # Drop foreign key constraint first op.drop_constraint("fk_todos_parent_id", "todos", type_="foreignkey") # Drop the column op.drop_column("todos", "parent_id") # ### end Alembic commands ###