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

chore(db): ensure query_context is MediumText before viz migration #20936

Merged
merged 1 commit into from
Aug 8, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
Create Date: 2022-06-30 22:04:17.686635

"""
from alembic import op
from sqlalchemy.dialects.mysql.base import MySQLDialect

from superset.migrations.shared.migrate_viz import MigrateTreeMap

# revision identifiers, used by Alembic.
Expand All @@ -29,6 +32,14 @@


def upgrade():
# Ensure `slice.params` and `slice.query_context`` in MySQL is MEDIUMTEXT
# before migration, as the migration will save a duplicate form_data backup
# which may significantly increase the size of these fields.
if isinstance(op.get_bind().dialect, MySQLDialect):
# If the columns are already MEDIUMTEXT, this is a no-op
op.execute("ALTER TABLE slices MODIFY params MEDIUMTEXT")
Copy link
Member

Choose a reason for hiding this comment

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

@ktmud why raw SQL here and not the Alembic alter_column method?

Copy link
Member Author

@ktmud ktmud Aug 2, 2022

Choose a reason for hiding this comment

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

Because this is only for one dialect and raw SQL is easier to read. People can also copy the statement directly if they ever want to test it manually.

op.execute("ALTER TABLE slices MODIFY query_context MEDIUMTEXT")

MigrateTreeMap.upgrade()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@
Create Date: 2022-07-19 15:16:06.091961

"""
from alembic import op
from sqlalchemy.dialects.mysql.base import MySQLDialect

# revision identifiers, used by Alembic.
revision = "a39867932713"
down_revision = "06e1e70058c7"

from alembic import op
from sqlalchemy.dialects.mysql.base import MySQLDialect


def upgrade():
if isinstance(op.get_bind().dialect, MySQLDialect):
Expand Down