-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
[WiP] Introduce uuids to power ImportExportMixin #7829
Conversation
Exports/imports will work better if we generate and use UUIDs as a basis for upserting objects.
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 feature 👍 A few quick comments:
"""Add a uuid column to a given table""" | ||
print(f"Add uuid column to table '{tbl_name}'") | ||
with op.batch_alter_table(tbl_name) as batch_op: | ||
batch_op.add_column(Column("uuid", CHAR(36), default=get_uuid)) |
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.
I would suggest using UUIDType from SQLAlchemy-Utils, as it will automatically leverage native UUID support where available (falls back to BINARY(16)
or CHAR(32)
where not available). This will introduce a new dependency, but the project is actively maintained, of high quality in my experience, and the license should be ok (BSD).
|
||
|
||
def get_uuid(): | ||
return str(uuid.uuid4()) |
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.
If we opt to use UUIDType
, this shouldn't need to be cast to str
(I believe).
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue |
WIP!