Replies: 4 comments
-
This seems more appropriate as a discussiong, moving there. |
Beta Was this translation helpful? Give feedback.
-
Hi @nihal1294,
Could you share how you'd expect this to work? Follow-up q:
|
Beta Was this translation helpful? Give feedback.
-
I assume that the reason to run the Here's how the proposed approach would work:
This approach separates schema management from the LiteLLM server, improving safety and maintainability. It requires minimal changes to the current workflow while aligning with database best practices. |
Beta Was this translation helpful? Give feedback.
-
To do this, I would suggest versioning the schema and maintaining this version in one of the tables so that you can verify this version on proxy server startup, and show an appropriate log message, and/or stop the server. Here's a code snippet to check for a schema mismatch between what LiteLLM expects and what's actually in the database.
If using another table for schema versioning is not desirable, we can also use a consistent checksum, say sha256 for the schema versioning, and just compare the new schema hash to check if that matches with the deployed schema hash. This can be done in a similar way to the above code snippet. Let me know if you need help with this. |
Beta Was this translation helpful? Give feedback.
-
Current Approach
I noticed that the current implementation uses the
prisma db push --accept-data-loss
command as part of the setup process every time the proxy server starts. While this approach works, it carries significant risks:Suggested Implementation:
Questions:
Motivation
The official Prisma documentation explicitly advises against using Prisma db push in production environments:
Prototyping your schema
The documentation states that db push is meant for quick schema prototyping, not for managing production database schemas. Using it in a production setting goes against best practices and puts data at risk.
Furthermore, it is mentioned in the documentation that
prisma migrate dev
is also a development-only command and should never be used in production environments due to its reliance on a shadow database and potential database resets.Development and production
Alternative Solution:
Implement a separate, decoupled database migration process that:
Replace the current Prisma db push approach with Prisma Migrate:
For development:
prisma migrate dev
This command creates a new migration, applies it to the database, and updates the Prisma client. The generated migration files should be committed to the repo.
For production:
prisma migrate deploy
This command applies all pending migrations, ensuring the database schema is up-to-date without risking data loss.
These commands should be run during the deployment process, not within the proxy server initialization.
Implementing this change would enhance the robustness and safety of the setup process, making it more suitable for production use. I believe this improvement aligns with the project's goal of providing a reliable and scalable solution for interacting with various LLM APIs.
Benefits:
Note
For whatever reason if this proposed solution is not preferred or not suitable for the proxy server, at the very least, there should be an option to disable running of the
prisma db push --accept-data-loss
command when running the proxy server, via an argument variable or the config file, to make it more suitable to use in a production deployment reliably.Twitter / LinkedIn details
Twitter: @nihal1294
Beta Was this translation helpful? Give feedback.
All reactions