-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
[migration] add unique constraint on dashboard_slices table #7880
[migration] add unique constraint on dashboard_slices table #7880
Conversation
3044d05
to
0e1f0b7
Compare
Codecov Report
@@ Coverage Diff @@
## master #7880 +/- ##
=======================================
Coverage 65.83% 65.83%
=======================================
Files 461 461
Lines 22210 22210
Branches 2425 2425
=======================================
Hits 14621 14621
Misses 7468 7468
Partials 121 121
Continue to review full report at Codecov.
|
"uq_dashboard_slice", "dashboard_slices", ["dashboard_id", "slice_id"] | ||
) | ||
except Exception: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a logging.error
/ logging.exception(e)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
a9f343e
to
dfc95ef
Compare
@graceguo-supercat you'll have to update the model to include the uniqueness constraint as well. |
0b3eff4
to
5d5f49f
Compare
5d5f49f
to
6dd187a
Compare
@mistercrunch This PR always failed at a postgres unit test, even after i rebased onto master branch. But i am not sure this is related to my code change. Do you have a clue why it is failing? thanks!
-------------------- >> begin captured logging << -------------------- |
trying to fix flaky unit test in #7898. |
6dd187a
to
3d4eda2
Compare
after rebased onto #7898, no flaky failure any more! |
|
||
def downgrade(): | ||
try: | ||
op.drop_constraint(u"uq_dashboard_slice", "dashboard_slices", type_="unique") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit. You don't need the u
prefix here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the note above.
) | ||
|
||
# add unique constraint | ||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@graceguo-supercat if you use the batch_alter_table
context manager (see here for an example) you shouldn't need to special case the the SQLite logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix as suggested.
3d4eda2
to
d24b59f
Compare
1. remove duplicated entries in many-to-many relation tbl dashboard_slices 2. add unique constraint on tbl 3. update the model to include the uniqueness constraint
d24b59f
to
5357679
Compare
CATEGORY
Choose one
SUMMARY
Superset didn't have unique constraint on dashboard_sliced table. In dashboard front-end code and when saving dashboard data to db, we added logic to prevent same slice id added into dashboard, but still found some duplicated entries in the dashboard_slices table.
When user tried to remove the duplicated slice_id from dashboard, they will see following error, and they cannot remove that duplicated slice:
![Screen Shot 2018-11-20 at 1 19 54 PM (5)](https://user-images.githubusercontent.com/27990562/61324852-3837f580-a7c8-11e9-8c8b-2ee4b388a91f.png)
Solution:
TEST PLAN
run following query from database, should get 0 row:
ADDITIONAL INFORMATION
REVIEWERS
@mistercrunch @john-bodley @michellethomas @etr2460