Skip to content

Commit

Permalink
Model for the annotation_metadata table
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospri committed Oct 4, 2023
1 parent a59b3dc commit 2e92cd2
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.annotation_slim import AnnotationSlim
from h.models.auth_client import AuthClient
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"

annotation_id = sa.Column(
sa.Integer,
sa.ForeignKey("annotation_slim.id", ondelete="cascade"),
nullable=False,
unique=True,
primary_key=True,
)
"""FK to annotation_slim.id"""

data = sa.Column(
MutableDict.as_mutable(pg.JSONB),
default=dict,
server_default=sa.func.jsonb("{}"),
nullable=True,
)

0 comments on commit 2e92cd2

Please sign in to comment.