"""initial schema Revision ID: 59dd2d9071fd Revises: Create Date: 2026-02-15 17:42:19.160196 """ 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 = '59dd2d9071fd' down_revision: Union[str, None] = None branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.create_table('adapters', sa.Column('name', sa.String(length=255), nullable=False), sa.Column('provider', sa.String(length=50), nullable=False), sa.Column('config', postgresql.JSONB(astext_type=sa.Text()), nullable=False), sa.Column('capabilities', postgresql.ARRAY(sa.String()), nullable=False), sa.Column('id', sa.UUID(), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.PrimaryKeyConstraint('id') ) op.create_table('labels', sa.Column('name', sa.String(length=100), nullable=False), sa.Column('color', sa.String(length=7), nullable=True), sa.Column('id', sa.UUID(), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name') ) op.create_table('projects', sa.Column('name', sa.String(length=255), nullable=False), sa.Column('slug', sa.String(length=255), nullable=False), sa.Column('description', sa.Text(), nullable=True), sa.Column('git_repo', sa.String(length=500), nullable=True), sa.Column('id', sa.UUID(), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('slug') ) op.create_table('agents', sa.Column('name', sa.String(length=255), nullable=False), sa.Column('slug', sa.String(length=255), nullable=False), sa.Column('adapter_id', sa.UUID(), nullable=False), sa.Column('system_prompt', sa.Text(), nullable=True), sa.Column('subscription_mode', sa.String(length=20), nullable=False), sa.Column('max_concurrent', sa.Integer(), nullable=False), sa.Column('timeout_seconds', sa.Integer(), nullable=False), sa.Column('status', sa.String(length=20), nullable=False), sa.Column('host', sa.String(length=255), nullable=True), sa.Column('pid', sa.Integer(), nullable=True), sa.Column('restart_count', sa.Integer(), nullable=False), sa.Column('id', sa.UUID(), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.ForeignKeyConstraint(['adapter_id'], ['adapters.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('slug') ) op.create_table('tasks', sa.Column('project_id', sa.UUID(), nullable=False), sa.Column('parent_id', sa.UUID(), nullable=True), sa.Column('title', sa.String(length=500), nullable=False), sa.Column('description', sa.Text(), nullable=True), sa.Column('status', sa.String(length=20), nullable=False), sa.Column('priority', sa.String(length=20), nullable=False), sa.Column('requires_pr', sa.Boolean(), nullable=False), sa.Column('pr_url', sa.String(length=500), nullable=True), sa.Column('assigned_agent_id', sa.UUID(), nullable=True), sa.Column('position', sa.Integer(), nullable=False), sa.Column('id', sa.UUID(), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.ForeignKeyConstraint(['assigned_agent_id'], ['agents.id'], ), sa.ForeignKeyConstraint(['parent_id'], ['tasks.id'], ), sa.ForeignKeyConstraint(['project_id'], ['projects.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('chats', sa.Column('project_id', sa.UUID(), nullable=True), sa.Column('task_id', sa.UUID(), nullable=True), sa.Column('kind', sa.String(length=20), nullable=False), sa.Column('id', sa.UUID(), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.ForeignKeyConstraint(['project_id'], ['projects.id'], ), sa.ForeignKeyConstraint(['task_id'], ['tasks.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('task_dependencies', sa.Column('task_id', sa.UUID(), nullable=False), sa.Column('depends_on_id', sa.UUID(), nullable=False), sa.Column('id', sa.UUID(), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.ForeignKeyConstraint(['depends_on_id'], ['tasks.id'], ), sa.ForeignKeyConstraint(['task_id'], ['tasks.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('task_files', sa.Column('task_id', sa.UUID(), nullable=False), sa.Column('filename', sa.String(length=500), nullable=False), sa.Column('mime_type', sa.String(length=100), nullable=True), sa.Column('file_path', sa.String(length=1000), nullable=False), sa.Column('uploaded_by', sa.UUID(), nullable=True), sa.Column('id', sa.UUID(), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.ForeignKeyConstraint(['task_id'], ['tasks.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('task_labels', sa.Column('task_id', sa.UUID(), nullable=False), sa.Column('label_id', sa.UUID(), nullable=False), sa.Column('id', sa.UUID(), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.ForeignKeyConstraint(['label_id'], ['labels.id'], ), sa.ForeignKeyConstraint(['task_id'], ['tasks.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('chat_messages', sa.Column('chat_id', sa.UUID(), nullable=False), sa.Column('sender_type', sa.String(length=20), nullable=False), sa.Column('sender_id', sa.UUID(), nullable=True), sa.Column('sender_name', sa.String(length=255), nullable=True), sa.Column('content', sa.Text(), nullable=False), sa.Column('id', sa.UUID(), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False), sa.ForeignKeyConstraint(['chat_id'], ['chats.id'], ), sa.PrimaryKeyConstraint('id') ) # ### end Alembic commands ### def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.drop_table('chat_messages') op.drop_table('task_labels') op.drop_table('task_files') op.drop_table('task_dependencies') op.drop_table('chats') op.drop_table('tasks') op.drop_table('agents') op.drop_table('projects') op.drop_table('labels') op.drop_table('adapters') # ### end Alembic commands ###