tomatoseveritysegmentationm.../migrations/versions/e5d7de4b3a28_initial_migration.py
Automated Action ab0e9b973a Implement tomato severity segmentation model API
- Set up FastAPI project structure with SQLite database
- Create database models for tomato images and severity classifications
- Implement image upload and processing endpoints
- Develop a segmentation model for tomato disease severity detection
- Add API endpoints for analysis and results retrieval
- Implement health check endpoint
- Set up Alembic for database migrations
- Update project documentation
2025-05-27 06:22:15 +00:00

58 lines
2.3 KiB
Python

"""Initial migration
Revision ID: e5d7de4b3a28
Revises:
Create Date: 2023-10-10 12:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'e5d7de4b3a28'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# Create tomato_images table
op.create_table('tomato_images',
sa.Column('id', sa.String(length=36), primary_key=True, index=True),
sa.Column('filename', sa.String(length=255), nullable=False),
sa.Column('file_path', sa.String(length=512), nullable=False, unique=True),
sa.Column('file_size', sa.Integer(), nullable=False),
sa.Column('mime_type', sa.String(length=50), nullable=False),
sa.Column('width', sa.Integer(), nullable=True),
sa.Column('height', sa.Integer(), nullable=True),
sa.Column('uploaded_at', sa.DateTime(), nullable=False),
)
# Create analysis_results table
op.create_table('analysis_results',
sa.Column('id', sa.String(length=36), primary_key=True, index=True),
sa.Column('image_id', sa.String(length=36), sa.ForeignKey('tomato_images.id', ondelete='CASCADE'), nullable=False),
sa.Column('model_name', sa.String(length=255), nullable=False),
sa.Column('model_version', sa.String(length=50), nullable=False),
sa.Column('primary_severity', sa.String(length=50), nullable=True),
sa.Column('severity_confidence', sa.Float(), nullable=True),
sa.Column('segmentation_data', sa.Text(), nullable=True),
sa.Column('processed_at', sa.DateTime(), nullable=False),
sa.Column('processing_time_ms', sa.Integer(), nullable=True),
)
# Create severity_details table
op.create_table('severity_details',
sa.Column('id', sa.String(length=36), primary_key=True, index=True),
sa.Column('analysis_id', sa.String(length=36), sa.ForeignKey('analysis_results.id', ondelete='CASCADE'), nullable=False),
sa.Column('severity_class', sa.String(length=50), nullable=False),
sa.Column('confidence', sa.Float(), nullable=False),
sa.Column('affected_area_percentage', sa.Float(), nullable=True),
)
def downgrade():
op.drop_table('severity_details')
op.drop_table('analysis_results')
op.drop_table('tomato_images')