-
Notifications
You must be signed in to change notification settings - Fork 14k
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
fix: drop check constraint on dbs to rename column #17275
fix: drop check constraint on dbs to rename column #17275
Conversation
Codecov Report
@@ Coverage Diff @@
## master #17275 +/- ##
==========================================
- Coverage 77.02% 77.02% -0.01%
==========================================
Files 1037 1037
Lines 55629 55629
Branches 7594 7594
==========================================
- Hits 42850 42848 -2
- Misses 12529 12531 +2
Partials 250 250
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
Alternatively, we can change the original db migration to not create a constraint in revision 1d9e835a84f9
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""empty message
Revision ID: 1d9e835a84f9
Revises: 3dda56f1c4c6
Create Date: 2018-07-16 18:04:07.764659
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.sql import expression
# revision identifiers, used by Alembic.
revision = "1d9e835a84f9"
down_revision = "3dda56f1c4c6"
def upgrade():
op.add_column(
"dbs",
sa.Column(
"allow_csv_upload",
sa.Boolean(create_constraint=False),
nullable=False,
server_default=expression.true(),
),
)
def downgrade():
op.drop_column("dbs", "allow_csv_upload")
Unfortunately that would work only for fresh installs. Everyone already using Superset has the constraint set in their databases, and if they're running it under MySQL 8 the only way to upgrade their DB with your migration is to drop the constraint. |
SUMMARY
The migration in #16756 is failing in MySQL 8. Renaming the column
dbs.allow_csv_upload
fails because there's a check constraint on it.This seems to be a known bug (sqlalchemy/alembic#699), and from that thread dropping the constraint seems safe. The problem is that existing installations already have the constraint, so we can't add
create_constraint=False
to boolean columns in the model.This PR fixes the migration by explicitly dropping the check constraint if it exists, and renaming the column after.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
Install Superset using a MySQL 8 database. The
superset db upgrade
step will fail on the migrationb92d69a6643c_rename_csv_to_file.py
.With this PR, the check constraint is dropped and the migration succeeds.
ADDITIONAL INFORMATION