Skip to content

Commit

Permalink
Model for annotation metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospri committed Sep 11, 2023
1 parent 215f464 commit b067cfe
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions h/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions h/models/annotation_metadata.py
Original file line number Diff line number Diff line change
@@ -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,
)

0 comments on commit b067cfe

Please sign in to comment.