Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Rewrite the user_filter migration again #6184

Merged
merged 2 commits into from
Oct 10, 2019
Merged

Conversation

richvdh
Copy link
Member

@richvdh richvdh commented Oct 8, 2019

you can't plausibly ALTER TABLE in sqlite, so we create the new table with the
right schema to start with.

you can't plausibly ALTER TABLE in sqlite, so we create the new table with the
right schema to start with.
@richvdh richvdh requested a review from a team October 8, 2019 11:28
"""
else:
select_clause = """
CREATE TEMPORARY TABLE user_filters_migration AS
SELECT * FROM user_filters GROUP BY user_id, filter_id;
SELECT * FROM user_filters GROUP BY user_id, filter_id
"""
sql = (
"""
BEGIN;
Copy link
Member

Choose a reason for hiding this comment

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

I think we're already in a transaction? Which would mean that the END would commit everything in the current transaction, which is probably not what we want

Copy link
Member Author

Choose a reason for hiding this comment

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

oh, hum. maybe? I don't think it's useful, anyway. will remove.

"""
else:
select_clause = """
CREATE TEMPORARY TABLE user_filters_migration AS
SELECT * FROM user_filters GROUP BY user_id, filter_id;
SELECT * FROM user_filters GROUP BY user_id, filter_id
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this work for both postgres and sqlite now?

Copy link
Member Author

Choose a reason for hiding this comment

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

no, postgres complains because filter_json is neither in the group by nor explicitly aggregated. I considered futzing around with something to pick an arbitrary filter_json from the results, but in the end decided to stick with pik's solution.

@richvdh richvdh merged commit 562b4e5 into develop Oct 10, 2019
@richvdh richvdh deleted the rav/user_filter_index_again branch October 10, 2019 10:28
babolivier pushed a commit that referenced this pull request Sep 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants