fix: Migration order due to cherry which went astray (#26160)
This commit is contained in:
parent
b7a9c220e1
commit
8644b1a319
|
|
@ -43,11 +43,9 @@ def table_has_column(table: str, column: str) -> bool:
|
|||
:param column: A column name
|
||||
:returns: True iff the column exists in the table
|
||||
"""
|
||||
config = op.get_context().config
|
||||
engine = engine_from_config(
|
||||
config.get_section(config.config_ini_section), prefix="sqlalchemy."
|
||||
)
|
||||
insp = reflection.Inspector.from_engine(engine)
|
||||
|
||||
insp = inspect(op.get_context().bind)
|
||||
|
||||
try:
|
||||
return any(col["name"] == column for col in insp.get_columns(table))
|
||||
except NoSuchTableError:
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ from sqlalchemy.ext.declarative import declarative_base
|
|||
from sqlalchemy.orm import Session
|
||||
|
||||
from superset import db
|
||||
from superset.migrations.shared.utils import paginated_update
|
||||
from superset.migrations.shared.utils import paginated_update, table_has_column
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
|
|
@ -45,6 +45,7 @@ class SqlaTable(Base):
|
|||
|
||||
|
||||
def upgrade():
|
||||
if not table_has_column("tables", "always_filter_main_dttm"):
|
||||
op.add_column(
|
||||
"tables",
|
||||
sa.Column(
|
||||
|
|
@ -64,4 +65,5 @@ def upgrade():
|
|||
|
||||
|
||||
def downgrade():
|
||||
if table_has_column("tables", "always_filter_main_dttm"):
|
||||
op.drop_column("tables", "always_filter_main_dttm")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
# 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.
|
||||
"""replay 317970b4400c
|
||||
|
||||
Revision ID: b7851ee5522f
|
||||
Revises: 4b85906e5b91
|
||||
Create Date: 2023-12-01 12:03:27.538945
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "b7851ee5522f"
|
||||
down_revision = "4b85906e5b91"
|
||||
|
||||
from importlib import import_module
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
module = import_module(
|
||||
"superset.migrations.versions.2023-09-06_13-18_317970b4400c_added_time_secondary_column_to_"
|
||||
)
|
||||
|
||||
|
||||
def upgrade():
|
||||
module.upgrade()
|
||||
|
||||
|
||||
def downgrade():
|
||||
module.downgrade()
|
||||
Loading…
Reference in New Issue