Skip to content

Commit

Permalink
fkn nightmare, dude.
Browse files Browse the repository at this point in the history
  • Loading branch information
Erutis committed Sep 4, 2024
1 parent 8980ecc commit d022e19
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/db-changes-var1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ jobs:
- 5432:5432

steps:
- name: Drop unwanted PostGIS extensions
run: |
psql -h localhost -U postgres -d postgres -c "DROP EXTENSION IF EXISTS postgis_tiger_geocoder CASCADE;"
psql -h localhost -U postgres -d postgres -c "DROP EXTENSION IF EXISTS postgis_topology CASCADE;"
psql -h localhost -U postgres -d postgres -c "DROP EXTENSION IF EXISTS fuzzystrmatch CASCADE;"
env:
PGPASSWORD: postgres

- name: Checkout Main Branch
uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion app/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ class FeedItem(GISBase):
class Trajectory(GISBase):
__tablename__ = "trajectory"
__table_args__ = {"schema": "gps"}
geom = mapped_column(Geometry("GEOMETRYZM"))
geom = mapped_column(Geometry("GEOMETRYZM", spatial_index=False))
feed_item_id = mapped_column(ForeignKey(FeedItem.id))
16 changes: 12 additions & 4 deletions docker/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

x-common-variables: &common-variables
POSTGRES_USER: nyc
POSTGRES_PASSWORD: gis #${POSTGRES_PASSWORD}
POSTGRES_DB: nyc
POSTGRES_HOST: db
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
POSTGRES_HOST: localhost
POSTGRES_DRIVERNAME: postgresql
PORT: 5432

Expand All @@ -16,6 +16,14 @@ services:
environment: *common-variables
ports:
- "5432:5432"
entrypoint: ["sh", "-c", "
docker-entrypoint.sh postgres &
until pg_isready -h localhost -p 5432; do sleep 1; done;
psql -h localhost -U postgres -d postgres -c 'DROP EXTENSION IF EXISTS postgis_tiger_geocoder CASCADE;';
psql -h localhost -U postgres -d postgres -c 'DROP EXTENSION IF EXISTS postgis_topology CASCADE;';
psql -h localhost -U postgres -d postgres -c 'DROP EXTENSION IF EXISTS fuzzystrmatch CASCADE;';
wait"] # Remove unwanted extensions


# db-setup: # create extensions & schemas
# container_name: db-setup
Expand Down
13 changes: 6 additions & 7 deletions migrations/env.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from logging.config import fileConfig
import os

from alembic import context
from logging.config import fileConfig
from sqlalchemy import create_engine, text
from sqlalchemy.schema import CreateSchema

from alembic import context

from app.tables import FeedItem, Trajectory, metadata

import os

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
Expand All @@ -31,13 +30,13 @@
# ... etc.

SCHEMATA = ["gps"]


url = os.getenv("DATABASE_URL")


def process_revision_directives(context, revision, directives):
"""Add necessary imports to new migration scripts."""
"""Customize script autogeneration."""

# Import geolalchemy in autogenerated scripts
script = directives[0]
script.imports.add("import geoalchemy2")

Expand Down
6 changes: 4 additions & 2 deletions migrations/test_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
# Standard libraries
import os
import random
import sys
import uuid

# from datetime import datetime

# External libraries
from sqlalchemy import create_engine, select
from sqlalchemy.orm import sessionmaker

# Add the parent directory to the Python path
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))

# Internal libraries
from app.tables import Trajectory, FeedItem

Expand Down

0 comments on commit d022e19

Please sign in to comment.