[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.
villebro
left a comment
There was a problem hiding this comment.
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.
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.
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!