-
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 sessions (#4961)
- Loading branch information
1 parent
6c53069
commit 83125e2
Showing
12 changed files
with
681 additions
and
26 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
55 changes: 55 additions & 0 deletions
55
src/phoenix/db/migrations/versions/4ded9e43755f_create_project_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,55 @@ | ||
"""create project_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( | ||
"project_sessions", | ||
sa.Column("id", sa.Integer, primary_key=True), | ||
sa.Column("session_id", sa.String, unique=True, nullable=False), | ||
sa.Column( | ||
"project_id", | ||
sa.Integer, | ||
sa.ForeignKey("projects.id", ondelete="CASCADE"), | ||
nullable=False, | ||
), | ||
sa.Column("start_time", sa.TIMESTAMP(timezone=True), index=True, nullable=False), | ||
sa.Column("end_time", sa.TIMESTAMP(timezone=True), index=True, nullable=False), | ||
) | ||
with op.batch_alter_table("traces") as batch_op: | ||
batch_op.add_column( | ||
sa.Column( | ||
"project_session_id", | ||
sa.Integer, | ||
sa.ForeignKey("project_sessions.id", ondelete="CASCADE"), | ||
nullable=True, | ||
), | ||
) | ||
op.create_index( | ||
"ix_traces_project_session_id", | ||
"traces", | ||
["project_session_id"], | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
op.drop_index("ix_traces_project_session_id") | ||
with op.batch_alter_table("traces") as batch_op: | ||
batch_op.drop_column("project_session_id") | ||
op.drop_table("project_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
Oops, something went wrong.