-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add db table for trace sessions
- Loading branch information
1 parent
23e9d82
commit 7113eb7
Showing
16 changed files
with
579 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/phoenix/db/migrations/versions/4ded9e43755f_create_trace_session_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"""create trace_session table | ||
Revision ID: 4ded9e43755f | ||
Revises: cd164e83824f | ||
Create Date: 2024-10-08 22:53:24.539786 | ||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "4ded9e43755f" | ||
down_revision: Union[str, None] = "cd164e83824f" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.create_table( | ||
"trace_sessions", | ||
sa.Column("id", sa.Integer, primary_key=True), | ||
sa.Column("session_id", sa.String, unique=True), | ||
sa.Column("project_id", sa.Integer, sa.ForeignKey("projects.id", ondelete="CASCADE")), | ||
sa.Column("start_time", sa.TIMESTAMP(timezone=True), index=True), | ||
sa.Column("end_time", sa.TIMESTAMP(timezone=True), index=True), | ||
) | ||
with op.batch_alter_table("traces") as batch_op: | ||
batch_op.add_column( | ||
sa.Column( | ||
"trace_session_id", | ||
sa.Integer, | ||
sa.ForeignKey("trace_sessions.id", ondelete="CASCADE"), | ||
nullable=True, | ||
), | ||
) | ||
op.create_index( | ||
"ix_traces_trace_session_id", | ||
"traces", | ||
["trace_session_id"], | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
op.drop_index("ix_traces_trace_session_id") | ||
with op.batch_alter_table("traces") as batch_op: | ||
batch_op.drop_column("trace_session_id") | ||
op.drop_table("trace_sessions") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.