mirror of
https://github.com/langgenius/dify.git
synced 2026-01-08 07:14:14 +00:00
feat: add ops trace (#5483)
Co-authored-by: takatost <takatost@gmail.com>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
"""update AppModelConfig and add table TracingAppConfig
|
||||
|
||||
Revision ID: 04c602f5dc9b
|
||||
Revises: 4e99a8df00ff
|
||||
Create Date: 2024-06-12 07:49:07.666510
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
import models as models
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '04c602f5dc9b'
|
||||
down_revision = '4ff534e1eb11'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('tracing_app_configs',
|
||||
sa.Column('id', models.StringUUID(), server_default=sa.text('uuid_generate_v4()'), nullable=False),
|
||||
sa.Column('app_id', models.StringUUID(), nullable=False),
|
||||
sa.Column('tracing_provider', sa.String(length=255), nullable=True),
|
||||
sa.Column('tracing_config', sa.JSON(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name='tracing_app_config_pkey')
|
||||
)
|
||||
with op.batch_alter_table('tracing_app_configs', schema=None) as batch_op:
|
||||
batch_op.create_index('tracing_app_config_app_id_idx', ['app_id'], unique=False)
|
||||
|
||||
with op.batch_alter_table('app_model_configs', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('trace_config', sa.Text(), nullable=True))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('app_model_configs', schema=None) as batch_op:
|
||||
batch_op.drop_column('trace_config')
|
||||
|
||||
with op.batch_alter_table('tracing_app_configs', schema=None) as batch_op:
|
||||
batch_op.drop_index('tracing_app_config_app_id_idx')
|
||||
|
||||
op.drop_table('tracing_app_configs')
|
||||
# ### end Alembic commands ###
|
||||
39
api/migrations/versions/2a3aebbbf4bb_add_app_tracing.py
Normal file
39
api/migrations/versions/2a3aebbbf4bb_add_app_tracing.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""add app tracing
|
||||
|
||||
Revision ID: 2a3aebbbf4bb
|
||||
Revises: c031d46af369
|
||||
Create Date: 2024-06-17 10:08:54.803701
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
import models as models
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '2a3aebbbf4bb'
|
||||
down_revision = 'c031d46af369'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('apps', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('tracing', sa.Text(), nullable=True))
|
||||
|
||||
with op.batch_alter_table('trace_app_config', schema=None) as batch_op:
|
||||
batch_op.create_index('tracing_app_config_app_id_idx', ['app_id'], unique=False)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('trace_app_config', schema=None) as batch_op:
|
||||
batch_op.drop_index('tracing_app_config_app_id_idx')
|
||||
|
||||
with op.batch_alter_table('apps', schema=None) as batch_op:
|
||||
batch_op.drop_column('tracing')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,66 @@
|
||||
"""remove app model config trace config and rename trace app config
|
||||
|
||||
Revision ID: c031d46af369
|
||||
Revises: 04c602f5dc9b
|
||||
Create Date: 2024-06-17 10:01:00.255189
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
import models as models
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'c031d46af369'
|
||||
down_revision = '04c602f5dc9b'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('trace_app_config',
|
||||
sa.Column('id', models.StringUUID(), server_default=sa.text('uuid_generate_v4()'), nullable=False),
|
||||
sa.Column('app_id', models.StringUUID(), nullable=False),
|
||||
sa.Column('tracing_provider', sa.String(length=255), nullable=True),
|
||||
sa.Column('tracing_config', sa.JSON(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('is_active', sa.Boolean(), server_default=sa.text('true'), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name='trace_app_config_pkey')
|
||||
)
|
||||
with op.batch_alter_table('trace_app_config', schema=None) as batch_op:
|
||||
batch_op.create_index('trace_app_config_app_id_idx', ['app_id'], unique=False)
|
||||
|
||||
with op.batch_alter_table('tracing_app_configs', schema=None) as batch_op:
|
||||
batch_op.drop_index('tracing_app_config_app_id_idx')
|
||||
|
||||
with op.batch_alter_table('app_model_configs', schema=None) as batch_op:
|
||||
batch_op.drop_column('trace_config')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('app_model_configs', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('trace_config', sa.TEXT(), autoincrement=False, nullable=True))
|
||||
|
||||
op.create_table('tracing_app_configs',
|
||||
sa.Column('id', sa.UUID(), server_default=sa.text('uuid_generate_v4()'), autoincrement=False, nullable=False),
|
||||
sa.Column('app_id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('tracing_provider', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
|
||||
sa.Column('tracing_config', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
|
||||
sa.Column('created_at', postgresql.TIMESTAMP(), server_default=sa.text('now()'), autoincrement=False, nullable=False),
|
||||
sa.Column('updated_at', postgresql.TIMESTAMP(), server_default=sa.text('now()'), autoincrement=False, nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name='trace_app_config_pkey')
|
||||
)
|
||||
with op.batch_alter_table('tracing_app_configs', schema=None) as batch_op:
|
||||
batch_op.create_index('trace_app_config_app_id_idx', ['app_id'], unique=False)
|
||||
|
||||
with op.batch_alter_table('trace_app_config', schema=None) as batch_op:
|
||||
batch_op.drop_index('trace_app_config_app_id_idx')
|
||||
|
||||
op.drop_table('trace_app_config')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user