feat: Initial commit with full deployment architecture and scripts
This commit is contained in:
commit
abb3efe114
96 files changed
+16789
No files matched your search
@@ -0,0 +1,101 @@
|
||||
"""Initial migration
|
||||
|
||||
Revision ID: 7e0f9be4da73
|
||||
Revises:
|
||||
Create Date: 2026-02-22 22:06:59.375138
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '7e0f9be4da73'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('agents',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=100), nullable=False),
|
||||
sa.Column('description', sa.Text(), nullable=True),
|
||||
sa.Column('icon_url', sa.String(length=255), nullable=True),
|
||||
sa.Column('dify_app_id', sa.String(length=100), nullable=False),
|
||||
sa.Column('dify_api_key', sa.String(length=100), nullable=False),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('dify_app_id')
|
||||
)
|
||||
op.create_table('users',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('username', sa.String(length=50), nullable=False),
|
||||
sa.Column('email', sa.String(length=100), nullable=False),
|
||||
sa.Column('department', sa.String(length=100), nullable=True),
|
||||
sa.Column('role', sa.String(length=20), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('email')
|
||||
)
|
||||
with op.batch_alter_table('users', schema=None) as batch_op:
|
||||
batch_op.create_index(batch_op.f('ix_users_username'), ['username'], unique=True)
|
||||
|
||||
op.create_table('chat_logs',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('conversation_id', sa.String(length=100), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('agent_id', sa.Integer(), nullable=False),
|
||||
sa.Column('query', sa.Text(), nullable=False),
|
||||
sa.Column('answer', sa.Text(), nullable=True),
|
||||
sa.Column('tokens_used', sa.Integer(), nullable=False),
|
||||
sa.Column('latency_ms', sa.Integer(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['agent_id'], ['agents.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
with op.batch_alter_table('chat_logs', schema=None) as batch_op:
|
||||
batch_op.create_index(batch_op.f('ix_chat_logs_agent_id'), ['agent_id'], unique=False)
|
||||
batch_op.create_index(batch_op.f('ix_chat_logs_conversation_id'), ['conversation_id'], unique=False)
|
||||
batch_op.create_index(batch_op.f('ix_chat_logs_created_at'), ['created_at'], unique=False)
|
||||
batch_op.create_index(batch_op.f('ix_chat_logs_user_id'), ['user_id'], unique=False)
|
||||
|
||||
op.create_table('user_agent_permissions',
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('agent_id', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['agent_id'], ['agents.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('user_id', 'agent_id')
|
||||
)
|
||||
op.create_table('feedbacks',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('chat_log_id', sa.Integer(), nullable=False),
|
||||
sa.Column('score', sa.Integer(), nullable=False),
|
||||
sa.Column('tags', sa.JSON(), nullable=True),
|
||||
sa.Column('comment', sa.Text(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['chat_log_id'], ['chat_logs.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('chat_log_id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('feedbacks')
|
||||
op.drop_table('user_agent_permissions')
|
||||
with op.batch_alter_table('chat_logs', schema=None) as batch_op:
|
||||
batch_op.drop_index(batch_op.f('ix_chat_logs_user_id'))
|
||||
batch_op.drop_index(batch_op.f('ix_chat_logs_created_at'))
|
||||
batch_op.drop_index(batch_op.f('ix_chat_logs_conversation_id'))
|
||||
batch_op.drop_index(batch_op.f('ix_chat_logs_agent_id'))
|
||||
|
||||
op.drop_table('chat_logs')
|
||||
with op.batch_alter_table('users', schema=None) as batch_op:
|
||||
batch_op.drop_index(batch_op.f('ix_users_username'))
|
||||
|
||||
op.drop_table('users')
|
||||
op.drop_table('agents')
|
||||
# ### end Alembic commands ###
|
||||
Reference in new issue
Block a user