File size: 1,990 Bytes
6859d42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""Add ToolSource table

Revision ID: 4af13678b83c
Revises: e2ca2546bf71
Create Date: 2025-05-03 18:51:11.601728

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = '4af13678b83c'
down_revision: Union[str, None] = 'e2ca2546bf71'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    # Manually corrected: Remove incorrect drop commands and add create_table for tool_sources
    op.create_table('tool_sources',
        sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
        sa.Column('github_url', sa.String(), nullable=False),
        sa.Column('description', sa.Text(), nullable=True),
        sa.Column('status', sa.String(), nullable=False, server_default='active'), # Match default from model
        sa.Column('last_checked_at', sa.DateTime(timezone=True), nullable=True),
        sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
        sa.PrimaryKeyConstraint('id', name=op.f('pk_tool_sources'))
    )
    with op.batch_alter_table('tool_sources', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_tool_sources_github_url'), ['github_url'], unique=True)
        batch_op.create_index(batch_op.f('ix_tool_sources_status'), ['status'], unique=False)

    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('tool_sources', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_tool_sources_status'))
        batch_op.drop_index(batch_op.f('ix_tool_sources_github_url'))

    op.drop_table('tool_sources')
    # ### end Alembic commands ###