Skip to content

Conversation

hayescode
Copy link
Contributor

@hayescode hayescode commented Aug 29, 2025

Caution

This is currently a mockup and incomplete. This has not been tested and will not run.

This is an initial draft for consolidating all SQL data layers using FastAPI's sqlmodel (Pydantic + SQL Alchemy).

For now I have created the new models in a new models/ directory and are duplicated from step.py, element.py, etc. The idea would be to delete those once this is ready.

The main reasons for this change are:

  1. Enable everyone who wants to use SQL data persistence to use a single implementation.
  2. Reduce technical debt and bugs, and speed up future development.

replaces #1365

Notes:

  • sqlmodel reserves the 'metadata' field for internal purposes and cannot be changed, so in Threads/Steps/User we have to rename this to something else so for now it's metadata_ instead, then aliased for proper database and API usage.

@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Aug 29, 2025
@asvishnyakov asvishnyakov marked this pull request as draft August 29, 2025 19:28
@dosubot dosubot bot added backend Pertains to the Python backend. data layer Pertains to data layers. labels Aug 29, 2025

Choose a reason for hiding this comment

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

I think the initial file should be the creation of the tables, right? So that new users do not have to problem to create the tables by themself.

Copy link
Contributor Author

@hayescode hayescode Sep 1, 2025

Choose a reason for hiding this comment

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

Today our SQL tables are stored in cameCase which is abnormal so my idea for the 1st migration would rename the problematic columns like threadId to thread_id. That would be the most "hands-off" migration. I have not actually done that here yet though.

Alternatively we could create brand new tables in a new database schema and use COPY INTO scripts.

I really don't think keeping these as camelCase would be good long term as we'd have to handle this into the future for all changes and it's not the right way to make SQL tables.

Copy link

This PR is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Sep 18, 2025
@asvishnyakov asvishnyakov added enhancement New feature or request keep-for-a-while Don’t mark as stale. This label should be used only for confirmed bugs or other important things labels Sep 18, 2025
@asvishnyakov
Copy link
Member

@github-actions Leave this PR open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Pertains to the Python backend. data layer Pertains to data layers. enhancement New feature or request keep-for-a-while Don’t mark as stale. This label should be used only for confirmed bugs or other important things size:XXL This PR changes 1000+ lines, ignoring generated files. stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQLAlchemy Data layer: Switch to more generic data layer with ORM AZURE SQL SUPPORT
3 participants