-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🗃️(api) make location address/coordinates unique together
Instead of having a unique `Localisation.adresse_station` field, let's be less pedantic and allow address to be unique while combined with specific coordinates. This allows to define a sparse address for a station with precise coordinates. Two stations located in the same area with a partial address will have two separated Localisation entries when their coordinates differ.
- Loading branch information
Showing
4 changed files
with
41 additions
and
2 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
33 changes: 33 additions & 0 deletions
33
src/api/qualicharge/migrations/versions/32b3d0e269a2_update_localisation_uniqueness_.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,33 @@ | ||
"""Update localisation uniqueness criterions | ||
Revision ID: 32b3d0e269a2 | ||
Revises: c09664a85912 | ||
Create Date: 2025-01-09 16:20:52.578289 | ||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "32b3d0e269a2" | ||
down_revision: Union[str, None] = "c09664a85912" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.drop_constraint( | ||
"localisation_adresse_station_key", "localisation", type_="unique" | ||
) | ||
op.create_unique_constraint( | ||
"localisation_adresse_station_coordonneesXY_key", "localisation", ["adresse_station", "coordonneesXY"] | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
op.drop_constraint("localisation_adresse_station_coordonneesXY_key", "localisation", type_="unique") | ||
op.create_unique_constraint( | ||
"localisation_adresse_station_key", "localisation", ["adresse_station"] | ||
) |
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
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