-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nik Sauer
committed
Jan 22, 2025
1 parent
3db7366
commit c73c589
Showing
5 changed files
with
191 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""add cascade | ||
Revision ID: 29dab04045ac | ||
Revises: 80277768fe1d | ||
Create Date: 2025-01-22 14:34:44.988247 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = '29dab04045ac' | ||
down_revision: Union[str, None] = '80277768fe1d' | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
pass | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
pass | ||
# ### end Alembic commands ### |
60 changes: 60 additions & 0 deletions
60
code/alembic/versions/5826b05428eb_added_cascade_to_all_fks.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
"""added cascade to all fks | ||
Revision ID: 5826b05428eb | ||
Revises: a344b0c7bf56 | ||
Create Date: 2025-01-22 14:46:33.823214 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = '5826b05428eb' | ||
down_revision: Union[str, None] = 'a344b0c7bf56' | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_constraint('cities_country_id_fkey', 'cities', type_='foreignkey') | ||
op.create_foreign_key(None, 'cities', 'countries', ['country_id'], ['id'], ondelete='CASCADE') | ||
op.drop_constraint('locations_country_id_fkey', 'locations', type_='foreignkey') | ||
op.drop_constraint('locations_city_id_fkey', 'locations', type_='foreignkey') | ||
op.create_foreign_key(None, 'locations', 'countries', ['country_id'], ['id'], ondelete='CASCADE') | ||
op.create_foreign_key(None, 'locations', 'cities', ['city_id'], ['id'], ondelete='CASCADE') | ||
op.drop_constraint('measurements_location_id_fkey', 'measurements', type_='foreignkey') | ||
op.drop_constraint('measurements_station_id_fkey', 'measurements', type_='foreignkey') | ||
op.create_foreign_key(None, 'measurements', 'stations', ['station_id'], ['id'], ondelete='CASCADE') | ||
op.create_foreign_key(None, 'measurements', 'locations', ['location_id'], ['id'], ondelete='CASCADE') | ||
op.drop_constraint('stationStatus_station_id_fkey', 'stationStatus', type_='foreignkey') | ||
op.create_foreign_key(None, 'stationStatus', 'stations', ['station_id'], ['id'], ondelete='CASCADE') | ||
op.drop_constraint('stations_location_id_fkey', 'stations', type_='foreignkey') | ||
op.create_foreign_key(None, 'stations', 'locations', ['location_id'], ['id'], ondelete='CASCADE') | ||
op.drop_constraint('values_measurement_id_fkey', 'values', type_='foreignkey') | ||
op.create_foreign_key(None, 'values', 'measurements', ['measurement_id'], ['id'], ondelete='CASCADE') | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_constraint(None, 'values', type_='foreignkey') | ||
op.create_foreign_key('values_measurement_id_fkey', 'values', 'measurements', ['measurement_id'], ['id']) | ||
op.drop_constraint(None, 'stations', type_='foreignkey') | ||
op.create_foreign_key('stations_location_id_fkey', 'stations', 'locations', ['location_id'], ['id']) | ||
op.drop_constraint(None, 'stationStatus', type_='foreignkey') | ||
op.create_foreign_key('stationStatus_station_id_fkey', 'stationStatus', 'stations', ['station_id'], ['id']) | ||
op.drop_constraint(None, 'measurements', type_='foreignkey') | ||
op.drop_constraint(None, 'measurements', type_='foreignkey') | ||
op.create_foreign_key('measurements_station_id_fkey', 'measurements', 'stations', ['station_id'], ['id']) | ||
op.create_foreign_key('measurements_location_id_fkey', 'measurements', 'locations', ['location_id'], ['id']) | ||
op.drop_constraint(None, 'locations', type_='foreignkey') | ||
op.drop_constraint(None, 'locations', type_='foreignkey') | ||
op.create_foreign_key('locations_city_id_fkey', 'locations', 'cities', ['city_id'], ['id']) | ||
op.create_foreign_key('locations_country_id_fkey', 'locations', 'countries', ['country_id'], ['id']) | ||
op.drop_constraint(None, 'cities', type_='foreignkey') | ||
op.create_foreign_key('cities_country_id_fkey', 'cities', 'countries', ['country_id'], ['id']) | ||
# ### end Alembic commands ### |
30 changes: 30 additions & 0 deletions
30
code/alembic/versions/a344b0c7bf56_changed_cascade_method.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""changed cascade method | ||
Revision ID: a344b0c7bf56 | ||
Revises: 29dab04045ac | ||
Create Date: 2025-01-22 14:39:45.568462 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = 'a344b0c7bf56' | ||
down_revision: Union[str, None] = '29dab04045ac' | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
pass | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
pass | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""fixed cascades | ||
Revision ID: b6289a85b50a | ||
Revises: 5826b05428eb | ||
Create Date: 2025-01-22 14:53:14.426837 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = 'b6289a85b50a' | ||
down_revision: Union[str, None] = '5826b05428eb' | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
pass | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
pass | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters