craig-rueda commented on a change in pull request #11019: URL: https://github.com/apache/incubator-superset/pull/11019#discussion_r494429866
########## File path: superset/migrations/versions/3fbbc6e8d654_fix_data_access_permissions_for_virtual_.py ########## @@ -0,0 +1,124 @@ +# 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. +"""fix data access permissions for virtual datasets + +Revision ID: 3fbbc6e8d654 +Revises: e5ef6828ac4e +Create Date: 2020-09-24 12:04:33.827436 + +""" + +# revision identifiers, used by Alembic. +revision = "3fbbc6e8d654" +down_revision = "e5ef6828ac4e" + +import re + +from alembic import op +from sqlalchemy import orm +from sqlalchemy.exc import SQLAlchemyError + + +def upgrade(): + """ + Previous sqla_viz behaviour when creating a virtual dataset was faulty + by creating an associated data access permission with [None] on the database name. + + This migration revision, fixes all faulty permissions that may exist on the db + Only fixes permissions that still have an associated dataset (fetch by id) + and replaces them with the current (correct) permission name + """ + from flask_appbuilder.security.sqla.models import ( + ViewMenu, Review comment: Should we be referencing concrete model classes in migrations? This migration will likely fail to run in the future should any of their structure change. Ideally, partial impl's, or copies should be defined directly in the migration in order to avoid such a situation. The other option is to roll all of these migrations up into a subset of what we currently have. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
