| 123456789101112131415161718192021222324252627282930313233343536373839 |
- """Add source and scan_data_path fields to Task model
- Revision ID: 004_add_task_source_field
- Revises: 003_add_session_token
- Create Date: 2026-01-24
- This migration adds support for CloudShell Scanner upload functionality:
- - source: Indicates whether the task was created via 'credential' scan or 'upload'
- - scan_data_path: Path to the uploaded JSON file for upload-based tasks
- """
- from alembic import op
- import sqlalchemy as sa
- # revision identifiers, used by Alembic.
- revision = '004_add_task_source_field'
- down_revision = '003_add_session_token'
- branch_labels = None
- depends_on = None
- def upgrade():
- """Add source and scan_data_path columns to tasks table"""
- # Add source column with default value 'credential'
- op.add_column('tasks',
- sa.Column('source', sa.String(20), nullable=True, server_default='credential'))
-
- # Add scan_data_path column for storing uploaded JSON file path
- op.add_column('tasks',
- sa.Column('scan_data_path', sa.String(500), nullable=True))
-
- # Update existing rows to have 'credential' as source
- op.execute("UPDATE tasks SET source = 'credential' WHERE source IS NULL")
- def downgrade():
- """Remove source and scan_data_path columns from tasks table"""
- op.drop_column('tasks', 'scan_data_path')
- op.drop_column('tasks', 'source')
|