-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
Update annotation model to have JSON Metadata field #5745
Changes from 11 commits
6c25f54
d3e83b0
770af9a
b23cfd3
cf017aa
3e68b4e
6220966
7691d96
70116b2
0a90aed
578b62d
9e9de8e
855a789
e44df93
b20dd92
8463a01
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"""add_metadata_column_to_annotation_model.py | ||
|
||
Revision ID: 40a0a483dd12 | ||
Revises: 1a1d627ebd8e | ||
Create Date: 2018-08-27 14:25:28.079119 | ||
|
||
""" | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '40a0a483dd12' | ||
down_revision = '1a1d627ebd8e' | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
def upgrade(): | ||
op.add_column('annotation', sa.Column('annotation_metadata', sa.Text(), nullable=True)) | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ class Annotation(Model, AuditMixinNullable): | |
layer = relationship( | ||
AnnotationLayer, | ||
backref='annotation') | ||
annotation_metadata = Column(Text) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Knowing that this is the Also could be nice to have |
||
|
||
__table_args__ = ( | ||
Index('ti_dag_state', layer_id, start_dttm, end_dttm), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,9 +22,12 @@ class AnnotationModelView(SupersetModelView, DeleteMixin): # noqa | |
add_title = _('Add Annotation') | ||
edit_title = _('Edit Annotation') | ||
|
||
list_columns = ['layer', 'short_descr', 'start_dttm', 'end_dttm'] | ||
list_columns = ['layer', 'short_descr', 'start_dttm', 'end_dttm', | ||
'annotation_metadata'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
edit_columns = [ | ||
'layer', 'short_descr', 'long_descr', 'start_dttm', 'end_dttm'] | ||
'layer', 'short_descr', 'long_descr', 'start_dttm', 'end_dttm', | ||
'annotation_metadata'] | ||
|
||
add_columns = edit_columns | ||
|
||
label_columns = { | ||
|
@@ -33,6 +36,12 @@ class AnnotationModelView(SupersetModelView, DeleteMixin): # noqa | |
'start_dttm': _('Start Dttm'), | ||
'end_dttm': _('End Dttm'), | ||
'long_descr': _('Long Descr'), | ||
'annotation_metadata': _('JSON Metadata'), | ||
} | ||
|
||
description_columns = { | ||
'annotation_metadata': 'This JSON represents any additional metadata this \ | ||
annotation needs to add more context.', | ||
} | ||
|
||
def pre_add(self, obj): | ||
|
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.
Migration should have a downgrade too. You can grep and find many other migrations that add_column on upgrade and remove_column on downgarde