Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(persistence): migrations support #2748

Merged
merged 11 commits into from
Apr 4, 2024
Merged

feat(persistence): migrations support #2748

merged 11 commits into from
Apr 4, 2024

Conversation

mikeldking
Copy link
Contributor

@mikeldking mikeldking commented Apr 4, 2024

resolves #2742
This adds runtime migration support via alembic.

NB: Migrations DO NOT work on in memory sqlite so Base.metadata.create_all() is necessary.

Of note that this PR adds naming convention rules as well.

@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Apr 4, 2024
@mikeldking mikeldking changed the base branch from main to sql April 4, 2024 01:37
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Apr 4, 2024
Copy link
Contributor

@RogerHYang RogerHYang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice!

src/phoenix/db/migrations/versions/cf03bd6bae1d_init.py Outdated Show resolved Hide resolved
sa.Column("id", sa.Integer, primary_key=True),
sa.Column("name", sa.String, nullable=False),
sa.Column("description", sa.String, nullable=True),
# TODO(mikeldking): is timezone=True necessary?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, it doesn't work with sqlite, because it just stores it as strings. I end up having to call isofomat() manually. Maybe this is useful for other vendors. Ultimately, having a timezone-aware python datetime should be the expectation.

@@ -51,6 +54,7 @@ class Trace(Base):
project_rowid: Mapped[int] = mapped_column(ForeignKey("projects.id"))
session_id: Mapped[Optional[str]]
trace_id: Mapped[str]
# TODO(mikeldking): why is the start and end time necessary? just filtering?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because there are moments in time where we can have multiple "root" spans (because the ultimate root has not arrived).

src/phoenix/db/models.py Show resolved Hide resolved
src/phoenix/db/migrate.py Outdated Show resolved Hide resolved
src/phoenix/db/migrate.py Outdated Show resolved Hide resolved
mikeldking and others added 4 commits April 4, 2024 09:25
Co-authored-by: Roger Yang <80478925+RogerHYang@users.noreply.github.com>
Co-authored-by: Roger Yang <80478925+RogerHYang@users.noreply.github.com>
@mikeldking mikeldking merged commit b56820d into sql Apr 4, 2024
12 checks passed
@mikeldking mikeldking deleted the migrate branch April 4, 2024 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants