-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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
chore: Add explicit ON DELETE CASCADE for dashboard_slices #24938
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
"""add on delete cascade for dashboard slices | ||
|
||
Revision ID: 8ace289026f3 | ||
Revises: 2e826adca42c | ||
Create Date: 2023-08-09 14:17:53.326191 | ||
|
||
""" | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "8ace289026f3" | ||
down_revision = "2e826adca42c" | ||
|
||
|
||
from superset.migrations.shared.constraints import ForeignKey, redefine | ||
|
||
foreign_keys = [ | ||
ForeignKey( | ||
table="dashboard_slices", | ||
referent_table="dashboards", | ||
local_cols=["dashboard_id"], | ||
remote_cols=["id"], | ||
), | ||
ForeignKey( | ||
table="dashboard_slices", | ||
referent_table="slices", | ||
local_cols=["slice_id"], | ||
remote_cols=["id"], | ||
), | ||
] | ||
|
||
|
||
def upgrade(): | ||
for foreign_key in foreign_keys: | ||
redefine(foreign_key, on_delete="CASCADE") | ||
|
||
|
||
def downgrade(): | ||
for foreign_key in foreign_keys: | ||
redefine(foreign_key) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,12 +207,10 @@ def test_users_can_view_own_dashboard(self): | |
dash.dashboard_title = "My Dashboard" | ||
dash.slug = my_dash_slug | ||
dash.owners = [user] | ||
dash.slices = [] | ||
|
||
hidden_dash = Dashboard() | ||
hidden_dash.dashboard_title = "Not My Dashboard" | ||
hidden_dash.slug = not_my_dash_slug | ||
hidden_dash.slices = [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See previous. |
||
|
||
db.session.add(dash) | ||
db.session.add(hidden_dash) | ||
|
@@ -277,7 +275,6 @@ def test_user_can_not_view_unpublished_dash(self): | |
dash.dashboard_title = "My Dashboard" | ||
dash.slug = slug | ||
dash.owners = [admin_user] | ||
dash.slices = [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See previous. |
||
dash.published = False | ||
db.session.add(dash) | ||
db.session.commit() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -186,8 +186,6 @@ def test_raise_for_access_dashboard_as_guest_no_rbac(self): | |
# Create a draft dashboard that is not embedded | ||
dash = Dashboard() | ||
dash.dashboard_title = "My Dashboard" | ||
dash.owners = [] | ||
dash.slices = [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See previous. |
||
dash.published = False | ||
db.session.add(dash) | ||
db.session.commit() | ||
|
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.
My default this is an empty list.