sadpandajoe commented on code in PR #40695: URL: https://github.com/apache/superset/pull/40695#discussion_r3358336732
########## superset/migrations/versions/2026-06-02_10-00_f7a1c93e0b21_add_sessions_invalidated_at.py: ########## @@ -0,0 +1,67 @@ +# 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 sessions_invalidated_at to user_attribute + +Revision ID: f7a1c93e0b21 +Revises: 33d7e0e21daa +Create Date: 2026-06-02 10:00:00.000000 + +""" + +import sqlalchemy as sa +from alembic import op + +from superset.migrations.shared.utils import ( + add_columns, + create_index, + drop_columns, + drop_index, +) + +# revision identifiers, used by Alembic. +revision = "f7a1c93e0b21" +down_revision = "33d7e0e21daa" + +TABLE = "user_attribute" +COLUMN = "sessions_invalidated_at" +INDEX = "ix_user_attribute_sessions_invalidated_at" +UQ = "uq_user_attribute_user_id" + + +def upgrade(): + add_columns(TABLE, sa.Column(COLUMN, sa.DateTime(), nullable=True)) + create_index(TABLE, INDEX, [COLUMN]) + # The model treats ``user_attribute`` as one row per user (all readers use + # ``extra_attributes[0]``). Enforce that invariant so the session-invalidation + # upsert is race-safe. Drop any pre-existing duplicates, keeping the lowest + # ``id`` per user, before adding the unique constraint. + op.execute( Review Comment: This drops `avatar_url` / `welcome_dashboard_id` from any `non-MIN(id)` row without merging them into the kept row. Operators upgrading from deployments with duplicates will silently lose those settings. Shouldn't we merge non-NULL fields first, or fail the migration with operator instructions for the duplicate-row case. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
