Skip to content
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

feat: Change DatasetArtifact.type from enum to String #7479

Merged
merged 1 commit into from
Mar 7, 2025

Conversation

Bento007
Copy link
Contributor

@Bento007 Bento007 commented Mar 6, 2025

Reason for Change

  • Changing DatasetArtifact.type from enum to String will make it easier to add new artifact types in the future without doing a database migration. This is safe because only the backend code has access to the database and will handle enforment.

Changes

  • add database migration to change DatasetArtifact.type from an enum to a string
  • update orm.py to make DatasetArtifact.type

Testing steps

  • tested the migration locally
  • Ran the migration on dev and verified existing datasets could be retrieved and that new datasets can be created.

Copy link
Contributor

github-actions bot commented Mar 6, 2025

Deployment Summary

@@ -68,5 +67,5 @@ class DatasetArtifactTable:
__tablename__ = "DatasetArtifact"

id = Column(UUID(as_uuid=True), primary_key=True)
type = Column(Enum(DatasetArtifactType))
type = Column(String)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can do this in a follow up PR, but it might make sense to use string literals that way you still have some type enforcement but passing strings makes it more flexible for db / API layer.

https://mypy.readthedocs.io/en/stable/literal_types.html

@Bento007 Bento007 merged commit 7ad1ac3 into feature/schema-5-3 Mar 7, 2025
66 of 71 checks passed
@Bento007 Bento007 deleted the tsmith/migrate-database branch March 7, 2025 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants