66 lines
2.6 KiB
Python
66 lines
2.6 KiB
Python
"""Add tasks and subtasks
|
|
|
|
Revision ID: f9ae19443d53
|
|
Revises: b74f27228a73
|
|
Create Date: 2026-08-08 02:50:58.197622
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = 'f9ae19443d53'
|
|
down_revision = 'b74f27228a73'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('task',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('title', sa.String(length=200), nullable=False),
|
|
sa.Column('description', sa.Text(), nullable=True),
|
|
sa.Column('status', sa.String(length=20), nullable=False),
|
|
sa.Column('priority', sa.String(length=20), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
|
sa.Column('due_date', sa.DateTime(), nullable=True),
|
|
sa.Column('completed_at', sa.DateTime(), nullable=True),
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
sa.Column('timer_seconds', sa.Integer(), nullable=False),
|
|
sa.Column('context', sa.String(length=100), nullable=True),
|
|
sa.Column('chunk_sessions', sa.JSON(), nullable=False),
|
|
sa.CheckConstraint("priority IN ('urgent', 'important', 'normal')", name='ck_task_priority'),
|
|
sa.CheckConstraint("status IN ('not_started', 'in_progress', 'done')", name='ck_task_status'),
|
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ondelete='CASCADE'),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
with op.batch_alter_table('task', schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f('ix_task_user_id'), ['user_id'], unique=False)
|
|
|
|
op.create_table('subtask',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('title', sa.String(length=100), nullable=False),
|
|
sa.Column('completed', sa.Boolean(), nullable=False),
|
|
sa.Column('task_id', sa.Integer(), nullable=False),
|
|
sa.ForeignKeyConstraint(['task_id'], ['task.id'], ondelete='CASCADE'),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
with op.batch_alter_table('subtask', schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f('ix_subtask_task_id'), ['task_id'], unique=False)
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table('subtask', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_subtask_task_id'))
|
|
|
|
op.drop_table('subtask')
|
|
with op.batch_alter_table('task', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_task_user_id'))
|
|
|
|
op.drop_table('task')
|
|
# ### end Alembic commands ###
|