Skip to content

Commit d7c22dc

Browse files
authored
Cascade release deletion to files (#3209)
1 parent 7739105 commit d7c22dc

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License");
2+
# you may not use this file except in compliance with the License.
3+
# You may obtain a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS,
9+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
# See the License for the specific language governing permissions and
11+
# limitations under the License.
12+
"""
13+
Cascade Release deletion to Files
14+
15+
Revision ID: 701c2fba1f5f
16+
Revises: b74a66a8f312
17+
Create Date: 2018-03-09 23:06:05.382680
18+
"""
19+
20+
from alembic import op
21+
22+
revision = '701c2fba1f5f'
23+
down_revision = 'b74a66a8f312'
24+
25+
26+
def upgrade():
27+
op.drop_constraint(
28+
'release_files_name_fkey', 'release_files', type_='foreignkey'
29+
)
30+
op.create_foreign_key(
31+
'release_files_name_fkey',
32+
'release_files',
33+
'releases', ['name', 'version'], ['name', 'version'],
34+
onupdate='CASCADE',
35+
ondelete='CASCADE'
36+
)
37+
38+
39+
def downgrade():
40+
op.drop_constraint(
41+
'release_files_name_fkey', 'release_files', type_='foreignkey'
42+
)
43+
op.create_foreign_key(
44+
'release_files_name_fkey',
45+
'release_files',
46+
'releases', ['name', 'version'], ['name', 'version'],
47+
onupdate='CASCADE'
48+
)

warehouse/packaging/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ def __table_args__(cls): # noqa
425425
["name", "version"],
426426
["releases.name", "releases.version"],
427427
onupdate="CASCADE",
428+
ondelete="CASCADE",
428429
),
429430

430431
CheckConstraint("sha256_digest ~* '^[A-F0-9]{64}$'"),

0 commit comments

Comments
 (0)