Skip to content
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

[dashboards] Increasing position_json to MEDIUMTEXT for MySQL #5618

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh nice! SQLAlchemy keeps on revealing its secrets :)