villebro commented on code in PR #24982: URL: https://github.com/apache/superset/pull/24982#discussion_r1294720602
########## superset/migrations/versions/2023-08-14_09-38_9f4a086c2676_add_normalize_columns_to_sqla_model.py: ########## @@ -0,0 +1,61 @@ +# 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. +"""add_normalize_columns_to_sqla_model + +Revision ID: 9f4a086c2676 +Revises: 4448fa6deeb1 +Create Date: 2023-08-14 09:38:11.897437 + +""" + +# revision identifiers, used by Alembic. +revision = '9f4a086c2676' +down_revision = '4448fa6deeb1' + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.orm import Session +from sqlalchemy.ext.declarative import declarative_base + +from superset import db +from superset.migrations.shared.utils import paginated_update + + +Base = declarative_base() + +class SqlaTable(Base): + __tablename__ = "tables" + + id = sa.Column(sa.Integer, primary_key=True) + normalize_columns = sa.Column(sa.Boolean) + + +def upgrade(): + op.add_column( + "tables", + sa.Column("normalize_columns", sa.Boolean(), nullable=True, default=False), Review Comment: It seems SQLAlchemy is slightly flaky when it comes to assigning default values with the NULL constraint in place. I dug around, and found that the `is_sqllab_viz` flag on the `SqlaTable` model is expected to work similarly, and there the migration also had to allow for `nullable=True`. So reverting back to that. -- 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