diff --git a/h/models/__init__.py b/h/models/__init__.py index dbb0ec0c221..c07fdaa9fdc 100644 --- a/h/models/__init__.py +++ b/h/models/__init__.py @@ -18,6 +18,7 @@ """ from h.models.activation import Activation from h.models.annotation import Annotation +from h.models.annotation_metadata import AnnotationMetadata from h.models.annotation_moderation import AnnotationModeration from h.models.auth_client import AuthClient from h.models.auth_ticket import AuthTicket diff --git a/h/models/annotation_metadata.py b/h/models/annotation_metadata.py new file mode 100644 index 00000000000..d5388155684 --- /dev/null +++ b/h/models/annotation_metadata.py @@ -0,0 +1,25 @@ +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql as pg +from sqlalchemy.ext.mutable import MutableDict + +from h.db import Base + + +class AnnotationMetadata(Base): + __tablename__ = "annotation_metadata" + + id = sa.Column(sa.Integer, autoincrement=True, primary_key=True) + + annotation_pk = sa.Column( + sa.Integer, + sa.ForeignKey("annotation.pk", ondelete="cascade"), + nullable=False, + unique=True, + ) + + data = sa.Column( + MutableDict.as_mutable(pg.JSONB), + default=dict, + server_default=sa.func.jsonb("{}"), + nullable=True, + )