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

Rewrite the user_filter migration again #6184

Merged
merged 2 commits into from Oct 10, 2019

Conversation

@richvdh
Copy link
Member

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 matrix-org/synapse-core Oct 8, 2019
@richvdh richvdh added this to In progress in Homeserver Task Board via automation Oct 8, 2019
@richvdh richvdh moved this from In progress to Review in Homeserver Task Board Oct 8, 2019
"""
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;

This comment has been minimized.

Copy link
@erikjohnston

erikjohnston Oct 9, 2019

Member

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

This comment has been minimized.

Copy link
@richvdh

richvdh Oct 9, 2019

Author Member

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

This comment has been minimized.

Copy link
@erikjohnston

erikjohnston Oct 9, 2019

Member

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

This comment has been minimized.

Copy link
@richvdh

richvdh Oct 9, 2019

Author Member

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 requested a review from erikjohnston Oct 9, 2019
@richvdh richvdh self-assigned this Oct 10, 2019
@richvdh richvdh merged commit 562b4e5 into develop Oct 10, 2019
18 checks passed
18 checks passed
buildkite/synapse Build #4876 passed (20 minutes, 51 seconds)
Details
buildkite/synapse/check-sample-config Passed (1 minute, 24 seconds)
Details
buildkite/synapse/check-style Passed (1 minute, 42 seconds)
Details
buildkite/synapse/isort Passed (16 seconds)
Details
buildkite/synapse/mypy Passed (23 seconds)
Details
buildkite/synapse/newspaper-newsfile Passed (15 seconds)
Details
buildkite/synapse/packaging Passed (17 seconds)
Details
buildkite/synapse/pipeline Passed (3 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-postgres-9-dot-5 Passed (18 minutes, 18 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-sqlite Passed (6 minutes, 35 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-sqlite-slash-old-deps Passed (7 minutes, 36 seconds)
Details
buildkite/synapse/python-3-dot-6-slash-sqlite Passed (5 minutes, 27 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-postgres-11 Passed (17 minutes, 51 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-postgres-9-dot-5 Passed (16 minutes, 51 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-sqlite Passed (6 minutes, 50 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-postgres-9-dot-6-slash-monolith Passed (11 minutes, 41 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-postgres-9-dot-6-slash-workers Passed (11 minutes, 50 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-sqlite-slash-monolith Passed (12 minutes, 2 seconds)
Details
Homeserver Task Board automation moved this from Review to Done Oct 10, 2019
@richvdh richvdh deleted the rav/user_filter_index_again branch Oct 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
2 participants
You can’t perform that action at this time.