mirror of
https://github.com/fawney19/Aether.git
synced 2026-01-02 15:52:26 +08:00
feat(db): add first_byte_time_ms column to usage table
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
"""add first_byte_time_ms to usage table
|
||||||
|
|
||||||
|
Revision ID: 180e63a9c83a
|
||||||
|
Revises: e9b3d63f0cbf
|
||||||
|
Create Date: 2025-12-15 17:07:44.631032+00:00
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '180e63a9c83a'
|
||||||
|
down_revision = 'e9b3d63f0cbf'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
"""应用迁移:升级到新版本"""
|
||||||
|
# 添加首字时间字段到 usage 表
|
||||||
|
op.add_column('usage', sa.Column('first_byte_time_ms', sa.Integer(), nullable=True))
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
"""回滚迁移:降级到旧版本"""
|
||||||
|
# 删除首字时间字段
|
||||||
|
op.drop_column('usage', 'first_byte_time_ms')
|
||||||
@@ -307,7 +307,8 @@ class Usage(Base):
|
|||||||
is_stream = Column(Boolean, default=False) # 是否为流式请求
|
is_stream = Column(Boolean, default=False) # 是否为流式请求
|
||||||
status_code = Column(Integer)
|
status_code = Column(Integer)
|
||||||
error_message = Column(Text, nullable=True)
|
error_message = Column(Text, nullable=True)
|
||||||
response_time_ms = Column(Integer) # 响应时间(毫秒)
|
response_time_ms = Column(Integer) # 总响应时间(毫秒)
|
||||||
|
first_byte_time_ms = Column(Integer, nullable=True) # 首字时间/TTFB(毫秒)
|
||||||
|
|
||||||
# 请求状态追踪
|
# 请求状态追踪
|
||||||
# pending: 请求开始处理中
|
# pending: 请求开始处理中
|
||||||
|
|||||||
Reference in New Issue
Block a user