
- Added TodoBoard model and BoardStatus enum
- Created migration for todo boards
- Added TodoBoard API endpoints
- Added board-related features to the README
🤖 Generated with BackendIM... (backend.im)
49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
"""add todo boards
|
|
|
|
Revision ID: 005
|
|
Revises: 004_add_subtasks_and_reminders
|
|
Create Date: 2025-05-12
|
|
|
|
"""
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.dialects import sqlite
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '005'
|
|
down_revision = '004_add_subtasks_and_reminders'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# Create todo_boards table
|
|
op.create_table(
|
|
'todo_boards',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(length=100), nullable=False),
|
|
sa.Column('description', sa.Text(), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)')),
|
|
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_todo_boards_id'), 'todo_boards', ['id'], unique=False)
|
|
|
|
# Add the status and board_id columns to the todos table
|
|
op.add_column('todos', sa.Column('status', sa.Enum('todo', 'in_progress', 'review', 'done', name='boardstatus'),
|
|
nullable=False, server_default='todo'))
|
|
op.add_column('todos', sa.Column('board_id', sa.Integer(), nullable=True))
|
|
op.create_foreign_key(None, 'todos', 'todo_boards', ['board_id'], ['id'], ondelete='SET NULL')
|
|
|
|
|
|
def downgrade():
|
|
# Drop foreign key constraint in sqlite
|
|
with op.batch_alter_table('todos') as batch_op:
|
|
batch_op.drop_constraint('fk_todos_board_id_todo_boards', type_='foreignkey')
|
|
batch_op.drop_column('board_id')
|
|
batch_op.drop_column('status')
|
|
|
|
# Drop the todo_boards table
|
|
op.drop_index(op.f('ix_todo_boards_id'), table_name='todo_boards')
|
|
op.drop_table('todo_boards') |