-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: simple Location model #35
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
alembic/versions/20231116_1432_b3b951e016d0_create_location_table.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,52 @@ | ||
"""Create Location table | ||
|
||
Revision ID: b3b951e016d0 | ||
Revises: 20145023aad0 | ||
Create Date: 2023-11-16 14:32:39.734937 | ||
|
||
""" | ||
from typing import Sequence, Union | ||
|
||
import sqlalchemy as sa | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "b3b951e016d0" | ||
down_revision: Union[str, None] = "20145023aad0" | ||
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.create_table( | ||
"locations", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("osm_id", sa.BigInteger(), nullable=True), | ||
sa.Column("osm_type", sa.String(length=255), nullable=True), | ||
sa.Column("osm_name", sa.String(), nullable=True), | ||
sa.Column("osm_display_name", sa.String(), nullable=True), | ||
sa.Column("osm_address_postcode", sa.String(), nullable=True), | ||
sa.Column("osm_address_city", sa.String(), nullable=True), | ||
sa.Column("osm_address_country", sa.String(), nullable=True), | ||
sa.Column("osm_lat", sa.Numeric(precision=11, scale=7), nullable=True), | ||
sa.Column("osm_lon", sa.Numeric(precision=11, scale=7), nullable=True), | ||
sa.Column( | ||
"created", | ||
sa.DateTime(timezone=True), | ||
server_default=sa.text("now()"), | ||
nullable=True, | ||
), | ||
sa.Column("updated", sa.DateTime(timezone=True), nullable=True), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.create_index(op.f("ix_locations_id"), "locations", ["id"], unique=False) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_index(op.f("ix_locations_id"), table_name="locations") | ||
op.drop_table("locations") | ||
# ### 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
from enum import Enum | ||
|
||
|
||
class PriceLocationOSMType(Enum): | ||
class LocationOSMType(Enum): | ||
NODE = "NODE" | ||
WAY = "WAY" | ||
RELATION = "RELATION" |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why don't we use osm_id as a primary key directly, as it's an INT?
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.
I'd rather not rely 100% on OSM. There's probably future locations that will not/never be in OSM. Like online stores, or temporary markets, or even closed locations 🤔...