hughhhh commented on code in PR #23614: URL: https://github.com/apache/superset/pull/23614#discussion_r1165671066
########## superset/migrations/versions/2023-03-27_12-30_7e67aecbf3f1_chart_ds_constraint.py: ########## @@ -0,0 +1,66 @@ +# 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. +"""chart-ds-constraint + +Revision ID: 7e67aecbf3f1 +Revises: b5ea9d343307 +Create Date: 2023-03-27 12:30:01.164594 + +""" + +# revision identifiers, used by Alembic. +revision = "7e67aecbf3f1" +down_revision = "07f9a902af1b" + +import sqlalchemy as sa +from alembic import op +from sqlalchemy.ext.declarative import declarative_base + +from superset import db + +Base = declarative_base() + + +class Slice(Base): # type: ignore + __tablename__ = "slices" + + id = sa.Column(sa.Integer, primary_key=True) + slice_name = sa.Column(sa.String(250)) + datasource_type = sa.Column(sa.String(200)) + query_context = sa.Column(sa.Text) + + +def upgrade(): + bind = op.get_bind() + session = db.Session(bind=bind) + + with op.batch_alter_table("slices") as batch_op: + for slc in session.query(Slice).filter(Slice.datasource_type != "table").all(): + # clean up all charts with datasource_type not != table + slc.datasource_type = "table" Review Comment: so the idea here was to try and see if some of them will work if we change the type, since we can't just delete these charts. We are assuming these charts are failing already and hoping this might help fix it, but no guarantee. Also now with the constraint we should see error when the user/api tries to write slice.datasource_type = query -- 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. To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org