Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(migration): add log for values unseen in Slice.datasource_type #23925

Merged
merged 14 commits into from
May 4, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
down_revision = "07f9a902af1b"

import json
import logging

import sqlalchemy as sa
from alembic import op
Expand All @@ -36,6 +37,8 @@

Base = declarative_base()

logger = logging.getLogger()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logging.getLogger(__name__)



class Slice(Base): # type: ignore
__tablename__ = "slices"
Expand Down Expand Up @@ -63,9 +66,15 @@ def upgrade():
session = db.Session(bind=bind)

with op.batch_alter_table("slices") as batch_op:
for slc in session.query(Slice).filter(Slice.datasource_type == "query").all():
upgrade_slc(slc)
session.add(slc)
for slc in session.query(Slice).filter(Slice.datasource_type != "table").all():
if slc.datasource_type == "query":
upgrade_slc(slc)
session.add(slc)

else:
logger.info(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.warn()

f"unknown value detected for slc.datasource_type: {slc.datasource_type}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest also putting a log into line 60 above in case that's where the failure is.

)

batch_op.create_check_constraint(
"ck_chart_datasource", "datasource_type in ('table')"
Expand Down