-
Notifications
You must be signed in to change notification settings - Fork 18
Change enum on history events to str #1379
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for thriving-cassata-78ae72 canceled.
|
| with op.batch_alter_table("history", schema=None) as batch_op: | ||
| batch_op.alter_column( | ||
| "entity_type", | ||
| existing_type=postgresql.ENUM( |
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.
Should this also drop the enum types from Postgres? Maybe with something like:
batch_op.execute("DROP TYPE IF EXISTS entitytype")
batch_op.execute("DROP TYPE IF EXISTS activitytype")
agorajek
left a comment
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.
@samredai this looks good, but I think you should try running this locally and post the outcome on the PR. Just left one comment inline.
| entity_type: Mapped[Optional[EntityType]] = mapped_column( | ||
| Enum(EntityType), | ||
| entity_type: Mapped[Optional[str]] = mapped_column( | ||
| String(20), |
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.
Why only 20?
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.
No reason, I just thought that the postgres default of infinite length seemed unnecessary for what will just be a string representation of an enum value. Should I make this larger? Or maybe don't specify the length at all?
Good idea, let me populate it with enum values locally then run a migration and see what happens to the data. |
|
@samredai is this still on your radar? That seems like a good idea. |
|
@agorajek thanks for the reminder comment. Time was tight this past week but I'll try to do this testing soon and get this in. |
Summary
This changes the enum type for activity type and entity type to a string, only in the database model. This will let us modify/extend the history events in the source code more easily without having to do database migrations.
Test Plan
make checkpassesmake testshows 100% unit test coverageDeployment Plan