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

Fix sqlite user_filters upgrade #15817

Merged
merged 4 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/15817.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix sqlite `user_filters` upgrade introduced in v1.86.0.
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ def run_upgrade(
full_user_id text NOT NULL,
user_id text NOT NULL,
filter_id bigint NOT NULL,
filter_json bytea NOT NULL,
UNIQUE (full_user_id),
UNIQUE (user_id)
filter_json bytea NOT NULL
)
"""
cur.execute(create_sql)
Expand All @@ -74,6 +72,12 @@ def run_upgrade(
"""
cur.execute(index_sql)

full_user_id_idx_sql = """
CREATE UNIQUE INDEX IF NOT EXISTS user_filters_full_user_id_unique ON
temp_user_filters (full_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.

Hmm, I think we need to add this to a new delta, otherwise for deployments where this file successfully run previously they'll end up with a different schema?

Copy link
Member

Choose a reason for hiding this comment

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

And we'll also potentially have to drop the incorrect indexes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And we'll also potentially have to drop the incorrect indexes.

This is referring to the indexes that were automatically created on the columns when the UNIQUE constraint was declared, correct?

Copy link
Member

Choose a reason for hiding this comment

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

Errr I just mean we'll need to undo the results of the bad upgrade, yes.

cur.execute(full_user_id_idx_sql)

copy_sql = """
INSERT INTO temp_user_filters (
user_id,
Expand Down