|
| 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 observation delete |
| 14 | +
|
| 15 | +Revision ID: 812e14a4cddf |
| 16 | +Revises: a073e7979805 |
| 17 | +Create Date: 2024-01-18 18:46:58.482270 |
| 18 | +""" |
| 19 | + |
| 20 | +from alembic import op |
| 21 | + |
| 22 | +revision = "812e14a4cddf" |
| 23 | +down_revision = "9a0ed2044b53" |
| 24 | + |
| 25 | + |
| 26 | +def upgrade(): |
| 27 | + op.drop_constraint( |
| 28 | + "project_observations_related_id_fkey", |
| 29 | + "project_observations", |
| 30 | + type_="foreignkey", |
| 31 | + ) |
| 32 | + op.create_foreign_key( |
| 33 | + None, |
| 34 | + "project_observations", |
| 35 | + "projects", |
| 36 | + ["related_id"], |
| 37 | + ["id"], |
| 38 | + onupdate="CASCADE", |
| 39 | + ondelete="CASCADE", |
| 40 | + ) |
| 41 | + op.drop_constraint( |
| 42 | + "release_observations_related_id_fkey", |
| 43 | + "release_observations", |
| 44 | + type_="foreignkey", |
| 45 | + ) |
| 46 | + op.create_foreign_key( |
| 47 | + None, |
| 48 | + "release_observations", |
| 49 | + "releases", |
| 50 | + ["related_id"], |
| 51 | + ["id"], |
| 52 | + onupdate="CASCADE", |
| 53 | + ondelete="CASCADE", |
| 54 | + ) |
| 55 | + |
| 56 | + |
| 57 | +def downgrade(): |
| 58 | + op.drop_constraint( |
| 59 | + "release_observations_related_id_fkey", |
| 60 | + "release_observations", |
| 61 | + type_="foreignkey", |
| 62 | + ) |
| 63 | + op.create_foreign_key( |
| 64 | + "release_observations_related_id_fkey", |
| 65 | + "release_observations", |
| 66 | + "releases", |
| 67 | + ["related_id"], |
| 68 | + ["id"], |
| 69 | + ) |
| 70 | + op.drop_constraint( |
| 71 | + "project_observations_related_id_fkey", |
| 72 | + "project_observations", |
| 73 | + type_="foreignkey", |
| 74 | + ) |
| 75 | + op.create_foreign_key( |
| 76 | + "project_observations_related_id_fkey", |
| 77 | + "project_observations", |
| 78 | + "projects", |
| 79 | + ["related_id"], |
| 80 | + ["id"], |
| 81 | + ) |
0 commit comments