
- Add SQLite database configuration - Create Todo model, schemas, and CRUD operations - Implement Todo API endpoints - Add Alembic migration for todo table - Set up database initialization in main.py - Update README with project details and instructions - Add pyproject.toml with Ruff configuration
42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
"""create todo table
|
|
|
|
Revision ID: 7f2ea9b3e5c8
|
|
Revises:
|
|
Create Date: 2023-06-10 16:00:00.000000
|
|
|
|
"""
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '7f2ea9b3e5c8'
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# Create the todo table
|
|
op.create_table(
|
|
'todo',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('title', sa.String(length=255), nullable=False),
|
|
sa.Column('description', sa.Text(), nullable=True),
|
|
sa.Column('completed', sa.Boolean(), nullable=False, default=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
|
|
# Create an index on the title column
|
|
op.create_index(op.f('ix_todo_id'), 'todo', ['id'], unique=False)
|
|
op.create_index(op.f('ix_todo_title'), 'todo', ['title'], unique=False)
|
|
|
|
|
|
def downgrade():
|
|
# Drop the indexes
|
|
op.drop_index(op.f('ix_todo_title'), table_name='todo')
|
|
op.drop_index(op.f('ix_todo_id'), table_name='todo')
|
|
|
|
# Drop the todo table
|
|
op.drop_table('todo') |