Skip to content

Commit

Permalink
feat: add reference and org_name fields
Browse files Browse the repository at this point in the history
  • Loading branch information
grejdi-mbta committed Jun 3, 2024
1 parent c2bbb4d commit acd1ada
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 1 deletion.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,18 @@ Import DMAP data into a PostgreSQL database
* run `docker-compose build` to build the docker images for local testing
* run `docker-compose up dmap_local_rds` to stand up a local postgres db
* this imnage could be used when running pytest
* run `docker-compose up dmap_importer` to run the importer application
* run `docker-compose up dmap_import` to run the importer application

### Outside of Docker

1. Navigate to repository directory.
2. Update `.env` variable. Source it `source .env`.
3. Run `poetry run start` to run the ingestion process.
4. Run `psql postgresql://postgres:[email protected]:5432/dmap_importer` to get into the database. Alternatively, after `docker-compose up`, you can:
1. `docker exec -it dmap_local_rds bash`
2. `psql -U postgres -d dmap_importer`
5. Run format, type and lint checker:
* `poetry run black .`
* `poetry run mypy .`
* `poetry run pylint src tests`
6. Run tests, `poetry run pytest`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""new reference org name columns
Revision ID: 0d3bf1348c58
Revises: d630193252db
Create Date: 2024-06-01 22:10:22.189820
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = "0d3bf1348c58"
down_revision: Union[str, None] = "d630193252db"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
op.add_column(
"use_transaction_longitudinal", sa.Column("reference", sa.String())
)
op.add_column(
"use_transaction_location", sa.Column("reference", sa.String())
)
op.add_column("sale_transaction", sa.Column("reference", sa.String()))
op.add_column("sale_transaction", sa.Column("org_name", sa.String()))


def downgrade() -> None:
op.drop_column("use_transaction_longitudinal", "reference")
op.drop_column("use_transaction_location", "reference")
op.drop_column("sale_transaction", "reference")
op.drop_column("sale_transaction", "org_name")
2 changes: 2 additions & 0 deletions src/dmap_import/schemas/sale_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,5 @@ class SaleTransaction(SqlBase):
discount_amount = sa.Column(sa.BigInteger, nullable=True)
_exported_dtm = sa.Column(sa.DateTime, nullable=True)
promotion_id = sa.Column(sa.String(), nullable=True)
reference = sa.Column(sa.String(), nullable=True)
org_name = sa.Column(sa.String(), nullable=True)
1 change: 1 addition & 0 deletions src/dmap_import/schemas/use_transaction_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,4 @@ class UseTransactionalLocation(SqlBase):
fare_rule_description = sa.Column(sa.String(), nullable=True)
_exported_dtm = sa.Column(sa.DateTime, nullable=True)
promotion_id = sa.Column(sa.String(), nullable=True)
reference = sa.Column(sa.String(), nullable=True)
1 change: 1 addition & 0 deletions src/dmap_import/schemas/use_transaction_longitudinal.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,4 @@ class UseTransactionalLongitudinal(SqlBase):
fare_rule_description = sa.Column(sa.String(), nullable=True)
_exported_dtm = sa.Column(sa.DateTime, nullable=True)
promotion_id = sa.Column(sa.String(), nullable=True)
reference = sa.Column(sa.String(), nullable=True)

0 comments on commit acd1ada

Please sign in to comment.