-
Notifications
You must be signed in to change notification settings - Fork 234
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
Schemas migrations #1179
Schemas migrations #1179
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the great work @aybruhm !
I added a couple of comments
agenta-backend/agenta_backend/migrations/20240110001454_initial_migration.py
Outdated
Show resolved
Hide resolved
…uman evaluation scenario
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now that we fixed the issue of the initialisation can we simply import the schemas instead of duplicating them here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work Abram!
We can, but it's not a good idea. Simply because duplicating the models in the migration file allows for a snapshot of the model's structure at the time of the migration. This snapshot will then be used to perform the necessary data and schema migrations without having to rely on the current state of the models, which is bound to change. |
Description
What was done:
If you have a look at any document record in the
app_variants
collection, you will notice that thebase
key for any record (in the collection) has been renamed tobases
and theconfig
key has been renamed toconfigs
. The reason why we have it this way is because we modified the field referencekey_name
while using odmantic. In order to migrate the records in our database and have beanie access the document field names, the record keys need to be renamed back to what is set in the model field. Otherwise, beanie would raise the error ->AttributeError: 'AppVariantDB' object has no attribute 'bases'
Example
i. Odmantic Model:
The record in the above model would be saved as:
ii. Beanie Document:
The record in the below model would be saved as:
Because our records are saved using odmantic, beanie would try to access base and config and would result in an attribute error (what exists instead is the key_name that was defined in odmantic reference, which in this case are: bases and configs).
Additional Information:
To migrate the changes, execute agenta-backend container in bash and run the following command:
To make use of the
--no-use-transaction
flag, kindly follow the guide here.