SuperAGI

Форк
0
/
44b0d6f2d1b3_init_models.py 
144 строки · 5.9 Кб
1
"""init models
2

3
Revision ID: 44b0d6f2d1b3
4
Revises: 
5
Create Date: 2023-06-01 11:55:35.195423
6

7
"""
8
from alembic import op
9
import sqlalchemy as sa
10

11

12
# revision identifiers, used by Alembic.
13
revision = '44b0d6f2d1b3'
14
down_revision = None
15
branch_labels = None
16
depends_on = None
17

18
from sqlalchemy.engine.reflection import Inspector
19

20
conn = op.get_bind()
21
inspector = Inspector.from_engine(conn)
22
tables = inspector.get_table_names()
23

24
def upgrade() -> None:
25
    # ### commands auto generated by Alembic - please adjust! ###
26
    if 'agent_configurations' not in tables:
27
        op.create_table('agent_configurations',
28
        sa.Column('created_at', sa.DateTime(), nullable=True),
29
        sa.Column('updated_at', sa.DateTime(), nullable=True),
30
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
31
        sa.Column('agent_id', sa.Integer(), nullable=True),
32
        sa.Column('key', sa.String(), nullable=True),
33
        sa.Column('value', sa.Text(), nullable=True),
34
        sa.PrimaryKeyConstraint('id')
35
        )
36
    if 'agent_execution_feeds' not in tables:
37
        op.create_table('agent_execution_feeds',
38
        sa.Column('created_at', sa.DateTime(), nullable=True),
39
        sa.Column('updated_at', sa.DateTime(), nullable=True),
40
        sa.Column('id', sa.Integer(), nullable=False),
41
        sa.Column('agent_execution_id', sa.Integer(), nullable=True),
42
        sa.Column('agent_id', sa.Integer(), nullable=True),
43
        sa.Column('feed', sa.Text(), nullable=True),
44
        sa.Column('role', sa.String(), nullable=True),
45
        sa.PrimaryKeyConstraint('id')
46
        )
47
    if 'agent_executions' not in tables:
48
        op.create_table('agent_executions',
49
        sa.Column('created_at', sa.DateTime(), nullable=True),
50
        sa.Column('updated_at', sa.DateTime(), nullable=True),
51
        sa.Column('id', sa.Integer(), nullable=False),
52
        sa.Column('status', sa.String(), nullable=True),
53
        sa.Column('agent_id', sa.Integer(), nullable=True),
54
        sa.Column('last_execution_time', sa.DateTime(), nullable=True),
55
        sa.PrimaryKeyConstraint('id')
56
        )
57
    if 'agents' not in tables:
58
        op.create_table('agents',
59
        sa.Column('created_at', sa.DateTime(), nullable=True),
60
        sa.Column('updated_at', sa.DateTime(), nullable=True),
61
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
62
        sa.Column('name', sa.String(), nullable=True),
63
        sa.Column('project_id', sa.Integer(), nullable=True),
64
        sa.Column('description', sa.String(), nullable=True),
65
        sa.PrimaryKeyConstraint('id')
66
        )
67
    if 'budgets' not in tables:
68
        op.create_table('budgets',
69
        sa.Column('created_at', sa.DateTime(), nullable=True),
70
        sa.Column('updated_at', sa.DateTime(), nullable=True),
71
        sa.Column('id', sa.Integer(), nullable=False),
72
        sa.Column('budget', sa.Float(), nullable=True),
73
        sa.Column('cycle', sa.String(), nullable=True),
74
        sa.PrimaryKeyConstraint('id')
75
        )
76
    if 'organisations' not in tables:
77
        op.create_table('organisations',
78
        sa.Column('created_at', sa.DateTime(), nullable=True),
79
        sa.Column('updated_at', sa.DateTime(), nullable=True),
80
        sa.Column('id', sa.Integer(), nullable=False),
81
        sa.Column('name', sa.String(), nullable=True),
82
        sa.Column('description', sa.String(), nullable=True),
83
        sa.PrimaryKeyConstraint('id')
84
        )
85
    if 'projects' not in tables:
86
        op.create_table('projects',
87
        sa.Column('created_at', sa.DateTime(), nullable=True),
88
        sa.Column('updated_at', sa.DateTime(), nullable=True),
89
        sa.Column('id', sa.Integer(), nullable=False),
90
        sa.Column('name', sa.String(), nullable=True),
91
        sa.Column('organisation_id', sa.Integer(), nullable=True),
92
        sa.Column('description', sa.String(), nullable=True),
93
        sa.PrimaryKeyConstraint('id')
94
        )
95
    if 'tool_configs' not in tables:
96
        op.create_table('tool_configs',
97
        sa.Column('created_at', sa.DateTime(), nullable=True),
98
        sa.Column('updated_at', sa.DateTime(), nullable=True),
99
        sa.Column('id', sa.Integer(), nullable=False),
100
        sa.Column('name', sa.String(), nullable=True),
101
        sa.Column('key', sa.String(), nullable=True),
102
        sa.Column('value', sa.String(), nullable=True),
103
        sa.Column('agent_id', sa.Integer(), nullable=True),
104
        sa.PrimaryKeyConstraint('id')
105
        )
106
    if 'tools' not in tables:
107
        op.create_table('tools',
108
        sa.Column('created_at', sa.DateTime(), nullable=True),
109
        sa.Column('updated_at', sa.DateTime(), nullable=True),
110
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
111
        sa.Column('name', sa.String(), nullable=True),
112
        sa.Column('folder_name', sa.String(), nullable=True),
113
        sa.Column('class_name', sa.String(), nullable=True),
114
        sa.Column('file_name', sa.String(), nullable=True),
115
        sa.PrimaryKeyConstraint('id')
116
        )
117
    if 'users' not in tables:
118
        op.create_table('users',
119
        sa.Column('created_at', sa.DateTime(), nullable=True),
120
        sa.Column('updated_at', sa.DateTime(), nullable=True),
121
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
122
        sa.Column('name', sa.String(), nullable=True),
123
        sa.Column('email', sa.String(), nullable=True),
124
        sa.Column('password', sa.String(), nullable=True),
125
        sa.Column('organisation_id', sa.Integer(), nullable=True),
126
        sa.PrimaryKeyConstraint('id'),
127
        sa.UniqueConstraint('email')
128
        )
129
    # ### end Alembic commands ###
130

131

132
def downgrade() -> None:
133
    # ### commands auto generated by Alembic - please adjust! ###
134
    op.drop_table('users')
135
    op.drop_table('tools')
136
    op.drop_table('tool_configs')
137
    op.drop_table('projects')
138
    op.drop_table('organisations')
139
    op.drop_table('budgets')
140
    op.drop_table('agents')
141
    op.drop_table('agent_executions')
142
    op.drop_table('agent_execution_feeds')
143
    op.drop_table('agent_configurations')
144
    # ### end Alembic commands ###
145

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.