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

Downgrading then upgrading redash schemas doesn't work #6836

Open
wlach opened this issue Mar 28, 2024 · 6 comments
Open

Downgrading then upgrading redash schemas doesn't work #6836

wlach opened this issue Mar 28, 2024 · 6 comments
Assignees

Comments

@wlach
Copy link
Contributor

wlach commented Mar 28, 2024

Issue Summary

After updating to latest main (1672cd9) and then downgrading to a previous version, upgrading again doesn't work unless you do the following:

alter table queries alter schedule drop default;
alter table queries alter options drop default;
alter table events alter additional_properties drop default;
alter table organizations alter settings drop default;
alter table alerts alter options drop default;
alter table dashboards alter options drop default;
alter table dashboards alter layout drop default;
alter table changes alter change drop default;
alter table visualizations alter options drop default;
alter table widgets alter options drop default;

The problem seems to be that this migration sets a default on downgrade, where none existed before. When you try to add a json schema to that, redash aborts.

Additional gotcha:

The "schedule" column gets casted to the "null" string on downgrade. You need to do a manual:

update queries set schedule=null where schedule='null';

Looks like the migrations modified in the following PRs are the culprits:

#6687
#6707
#6713

/cc @AndrewChubatiuk

@AndrewChubatiuk
Copy link
Collaborator

@wlach thanks for a finding
could you please submit PR with a fix?

@wlach
Copy link
Contributor Author

wlach commented Mar 29, 2024

@wlach thanks for a finding could you please submit PR with a fix?

Will see what I can do.

@wlach
Copy link
Contributor Author

wlach commented Apr 1, 2024

Found an additional gotcha (schedule for queries can get set to the string "null" on downgrade), updated description.

@justinclift
Copy link
Member

Oh, this all doesn't sound good.

Breaking the schema when downgrading is something we'd better fix.

The rough plan is to enable automatic schema upgrades when Redash starts (rather than a manual process). So being able to downgrade stuff when needed for some reason is probably pretty important.

@wlach
Copy link
Contributor Author

wlach commented Apr 3, 2024

Yeah, it's a bit unfortunate -- I assume the alembic db migrations were automatically generated, and were just wrong in this case. I think we need to verify (via pg_dump or similar) that the schema is as you'd expect after an arbitrary number of upgrades and downgrades.

FWIW my testing setup is to do this to downgrade:

./manage.py db downgrade fd4fc850d7ea

And this to upgrade:

./manage.py db upgrade

@wlach
Copy link
Contributor Author

wlach commented Apr 20, 2024

@wlach thanks for a finding could you please submit PR with a fix?

Will see what I can do.

Update: I haven't had time to look at this and am not sure when I will.

@justinclift justinclift self-assigned this Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants