Skip to content

Commit

Permalink
[dashboards] Increasing position_json to MEDIUMTEXT for MySQL
Browse files Browse the repository at this point in the history
  • Loading branch information
John Bodley committed Aug 13, 2018
1 parent 50981db commit eec969f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
36 changes: 36 additions & 0 deletions superset/migrations/versions/1a1d627ebd8e_position_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""position_json
Revision ID: 1a1d627ebd8e
Revises: 0c5070e96b57
Create Date: 2018-08-13 11:30:07.101702
"""

# revision identifiers, used by Alembic.
revision = '1a1d627ebd8e'
down_revision = '0c5070e96b57'

from alembic import op
import sqlalchemy as sa

from superset.utils import MediumText


def upgrade():
with op.batch_alter_table('dashboards') as batch_op:
batch_op.alter_column(
'position_json',
existing_type=sa.Text(),
type_=MediumText(),
existing_nullable=True,
)


def downgrade():
with op.batch_alter_table('dashboards') as batch_op:
batch_op.alter_column(
'position_json',
existing_type=MediumText(),
type_=sa.Text(),
existing_nullable=True,
)
3 changes: 2 additions & 1 deletion superset/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from superset.legacy import update_time_range
from superset.models.helpers import AuditMixinNullable, ImportMixin, set_perm
from superset.models.user_attributes import UserAttribute
from superset.utils import MediumText
from superset.viz import viz_types
install_aliases()
from urllib import parse # noqa
Expand Down Expand Up @@ -364,7 +365,7 @@ class Dashboard(Model, AuditMixinNullable, ImportMixin):
__tablename__ = 'dashboards'
id = Column(Integer, primary_key=True)
dashboard_title = Column(String(500))
position_json = Column(Text)
position_json = Column(MediumText())
description = Column(Text)
css = Column(Text)
json_metadata = Column(Text)
Expand Down
7 changes: 6 additions & 1 deletion superset/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
from pydruid.utils.having import Having
import pytz
import sqlalchemy as sa
from sqlalchemy import event, exc, select
from sqlalchemy import event, exc, select, Text
from sqlalchemy.dialects.mysql import MEDIUMTEXT
from sqlalchemy.types import TEXT, TypeDecorator

from superset.exceptions import SupersetException, SupersetTimeoutException
Expand Down Expand Up @@ -1011,3 +1012,7 @@ def get_username():
return g.user.username
except Exception:
pass


def MediumText():
return Text().with_variant(MEDIUMTEXT(), 'mysql')

0 comments on commit eec969f

Please sign in to comment.