SuperAGI
144 строки · 5.9 Кб
1"""init models
2
3Revision ID: 44b0d6f2d1b3
4Revises:
5Create Date: 2023-06-01 11:55:35.195423
6
7"""
8from alembic import op9import sqlalchemy as sa10
11
12# revision identifiers, used by Alembic.
13revision = '44b0d6f2d1b3'14down_revision = None15branch_labels = None16depends_on = None17
18from sqlalchemy.engine.reflection import Inspector19
20conn = op.get_bind()21inspector = Inspector.from_engine(conn)22tables = inspector.get_table_names()23
24def upgrade() -> None:25# ### commands auto generated by Alembic - please adjust! ###26if 'agent_configurations' not in tables:27op.create_table('agent_configurations',28sa.Column('created_at', sa.DateTime(), nullable=True),29sa.Column('updated_at', sa.DateTime(), nullable=True),30sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),31sa.Column('agent_id', sa.Integer(), nullable=True),32sa.Column('key', sa.String(), nullable=True),33sa.Column('value', sa.Text(), nullable=True),34sa.PrimaryKeyConstraint('id')35)36if 'agent_execution_feeds' not in tables:37op.create_table('agent_execution_feeds',38sa.Column('created_at', sa.DateTime(), nullable=True),39sa.Column('updated_at', sa.DateTime(), nullable=True),40sa.Column('id', sa.Integer(), nullable=False),41sa.Column('agent_execution_id', sa.Integer(), nullable=True),42sa.Column('agent_id', sa.Integer(), nullable=True),43sa.Column('feed', sa.Text(), nullable=True),44sa.Column('role', sa.String(), nullable=True),45sa.PrimaryKeyConstraint('id')46)47if 'agent_executions' not in tables:48op.create_table('agent_executions',49sa.Column('created_at', sa.DateTime(), nullable=True),50sa.Column('updated_at', sa.DateTime(), nullable=True),51sa.Column('id', sa.Integer(), nullable=False),52sa.Column('status', sa.String(), nullable=True),53sa.Column('agent_id', sa.Integer(), nullable=True),54sa.Column('last_execution_time', sa.DateTime(), nullable=True),55sa.PrimaryKeyConstraint('id')56)57if 'agents' not in tables:58op.create_table('agents',59sa.Column('created_at', sa.DateTime(), nullable=True),60sa.Column('updated_at', sa.DateTime(), nullable=True),61sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),62sa.Column('name', sa.String(), nullable=True),63sa.Column('project_id', sa.Integer(), nullable=True),64sa.Column('description', sa.String(), nullable=True),65sa.PrimaryKeyConstraint('id')66)67if 'budgets' not in tables:68op.create_table('budgets',69sa.Column('created_at', sa.DateTime(), nullable=True),70sa.Column('updated_at', sa.DateTime(), nullable=True),71sa.Column('id', sa.Integer(), nullable=False),72sa.Column('budget', sa.Float(), nullable=True),73sa.Column('cycle', sa.String(), nullable=True),74sa.PrimaryKeyConstraint('id')75)76if 'organisations' not in tables:77op.create_table('organisations',78sa.Column('created_at', sa.DateTime(), nullable=True),79sa.Column('updated_at', sa.DateTime(), nullable=True),80sa.Column('id', sa.Integer(), nullable=False),81sa.Column('name', sa.String(), nullable=True),82sa.Column('description', sa.String(), nullable=True),83sa.PrimaryKeyConstraint('id')84)85if 'projects' not in tables:86op.create_table('projects',87sa.Column('created_at', sa.DateTime(), nullable=True),88sa.Column('updated_at', sa.DateTime(), nullable=True),89sa.Column('id', sa.Integer(), nullable=False),90sa.Column('name', sa.String(), nullable=True),91sa.Column('organisation_id', sa.Integer(), nullable=True),92sa.Column('description', sa.String(), nullable=True),93sa.PrimaryKeyConstraint('id')94)95if 'tool_configs' not in tables:96op.create_table('tool_configs',97sa.Column('created_at', sa.DateTime(), nullable=True),98sa.Column('updated_at', sa.DateTime(), nullable=True),99sa.Column('id', sa.Integer(), nullable=False),100sa.Column('name', sa.String(), nullable=True),101sa.Column('key', sa.String(), nullable=True),102sa.Column('value', sa.String(), nullable=True),103sa.Column('agent_id', sa.Integer(), nullable=True),104sa.PrimaryKeyConstraint('id')105)106if 'tools' not in tables:107op.create_table('tools',108sa.Column('created_at', sa.DateTime(), nullable=True),109sa.Column('updated_at', sa.DateTime(), nullable=True),110sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),111sa.Column('name', sa.String(), nullable=True),112sa.Column('folder_name', sa.String(), nullable=True),113sa.Column('class_name', sa.String(), nullable=True),114sa.Column('file_name', sa.String(), nullable=True),115sa.PrimaryKeyConstraint('id')116)117if 'users' not in tables:118op.create_table('users',119sa.Column('created_at', sa.DateTime(), nullable=True),120sa.Column('updated_at', sa.DateTime(), nullable=True),121sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),122sa.Column('name', sa.String(), nullable=True),123sa.Column('email', sa.String(), nullable=True),124sa.Column('password', sa.String(), nullable=True),125sa.Column('organisation_id', sa.Integer(), nullable=True),126sa.PrimaryKeyConstraint('id'),127sa.UniqueConstraint('email')128)129# ### end Alembic commands ###130
131
132def downgrade() -> None:133# ### commands auto generated by Alembic - please adjust! ###134op.drop_table('users')135op.drop_table('tools')136op.drop_table('tool_configs')137op.drop_table('projects')138op.drop_table('organisations')139op.drop_table('budgets')140op.drop_table('agents')141op.drop_table('agent_executions')142op.drop_table('agent_execution_feeds')143op.drop_table('agent_configurations')144# ### end Alembic commands ###145