Skip to content

Commit 1c48fe0

Browse files
authored
fix: Update migration logic in apache#27119 (apache#28482)
1 parent 56f0fc4 commit 1c48fe0

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

UPDATING.md

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ assists people when migrating to a new version.
8484
### Potential Downtime
8585

8686
- [26416](https://github.com/apache/superset/pull/26416): Adds two database indexes to the `report_execution_log` table and one database index to the `report_recipient` to improve performance. Scheduled downtime may be required for large deployments.
87+
- [28482](https://github.com/apache/superset/pull/28482): Potentially augments the `query.executed_sql` and `query.select_sql` columns for MySQL from `MEDIUMTEXT` to `LONGTEXT`. Potential downtime may be required for large deployments which previously ran [27119](https://github.com/apache/superset/pull/27119).
8788

8889
## 3.1.0
8990

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
"""change_mediumtext_to_longtext
18+
Revision ID: f7b6750b67e8
19+
Revises: f84fde59123a
20+
Create Date: 2024-05-09 19:19:46.630140
21+
"""
22+
23+
# revision identifiers, used by Alembic.
24+
revision = "f7b6750b67e8"
25+
down_revision = "f84fde59123a"
26+
27+
from alembic import op # noqa: E402
28+
from sqlalchemy.dialects.mysql import MEDIUMTEXT # noqa: E402
29+
from sqlalchemy.dialects.mysql.base import MySQLDialect # noqa: E402
30+
31+
from superset.migrations.shared.utils import get_table_column # noqa: E402
32+
from superset.utils.core import LongText, MediumText # noqa: E402
33+
34+
35+
def upgrade():
36+
if isinstance(op.get_bind().dialect, MySQLDialect):
37+
for item in ["query.executed_sql", "query.select_sql"]:
38+
table_name, column_name = item.split(".")
39+
40+
if (column := get_table_column(table_name, column_name)) and isinstance(
41+
column["type"],
42+
MEDIUMTEXT,
43+
):
44+
with op.batch_alter_table(table_name) as batch_op:
45+
batch_op.alter_column(
46+
column_name,
47+
existing_type=MediumText(),
48+
type_=LongText(),
49+
existing_nullable=True,
50+
)
51+
52+
53+
def downgrade():
54+
pass

0 commit comments

Comments
 (0)