Skip to content

Commit

Permalink
[MDS-5811] gis_export_view migration (#3033)
Browse files Browse the repository at this point in the history
* added migration for gis materialized view and updated model

* update drop matview query

* created sql-prod migration folder and set it to only run in prod environment
  • Loading branch information
matbusby-fw authored Apr 4, 2024
1 parent 7604956 commit bdcf950
Show file tree
Hide file tree
Showing 8 changed files with 469 additions and 1 deletion.
1 change: 1 addition & 0 deletions docker-compose.M1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ services:
- PLATFORM=LOCAL
volumes:
- ./migrations/sql:/flyway/sql
- ./migrations/sql-prod:/flyway/sql-prod
- ./migrations/scripts:/flyway/scripts
depends_on:
- postgres
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ services:
- PLATFORM=LOCAL
volumes:
- ./migrations/sql:/flyway/sql
- ./migrations/sql-prod:/flyway/sql-prod
- ./migrations/scripts:/flyway/scripts
depends_on:
- postgres
Expand Down
1 change: 1 addition & 0 deletions migrations/Dockerfile.flyway.M1.dev
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ USER root
RUN apt-get update && apt-get install -y gettext

COPY sql/* /flyway/sql/
COPY sql-prod/* /flyway/sql-prod/
COPY scripts/* /flyway/scripts/

ENTRYPOINT /flyway/scripts/run_migrations.sh
2 changes: 2 additions & 0 deletions migrations/Dockerfile.flyway.ci
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ USER 0
RUN apk add gettext

COPY sql/* /flyway/sql/
COPY sql-prod/* /flyway/sql-prod/
COPY scripts/* /flyway/scripts/


ENV FLYWAY_VERSION=5.2.4

# Copy over the SQL files and scripts
COPY sql/* $FLYWAY_HOME/sql/
COPY sql-prod/* $FLYWAY_HOME/sql-prod/
COPY scripts/* $FLYWAY_HOME/scripts/

RUN chmod -R 777 $FLYWAY_HOME
Expand Down
1 change: 1 addition & 0 deletions migrations/Dockerfile.flyway.dev
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ USER root
RUN apk add gettext

COPY sql/* /flyway/sql/
COPY sql-prod/* /flyway/sql-prod/
COPY scripts/* /flyway/scripts/

ENTRYPOINT /flyway/scripts/run_migrations.sh
10 changes: 9 additions & 1 deletion migrations/scripts/run_migrations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ fi
# Make flyway binary discoverable
export PATH="$FLYWAY_HOME:$PATH"

ENVIRONMENT_NAME="${ENVIRONMENT_NAME:-dev}"

# Run migrations for mds database
flyway -validateMigrationNaming=true migrate
if [[ $ENVIRONMENT_NAME == 'prod' ]]; then
echo "---> Running prod migrations"
flyway -locations=filesystem:sql,filesystem:sql-prod -validateMigrationNaming=true migrate
else
echo "---> Running common migrations"
flyway -locations=filesystem:sql -validateMigrationNaming=true migrate
fi

# Run migrations for mds_test database
if [ "$PLATFORM" != "K8S" ]; then
Expand Down
451 changes: 451 additions & 0 deletions migrations/sql-prod/R__now_gis_export_materialized_view.sql

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class NowApplicationGisExport(Base):
now_latitude = db.Column(db.String)
now_longitude = db.Column(db.String)
verified_date = db.Column(db.String)
mine_purpose = db.Column(db.String)
latest_response_date = db.Column(db.String)
regional_contact = db.Column(db.String)

# Notice of Work Details
is_applicant_individual_or_company = db.Column(db.String)
Expand Down

0 comments on commit bdcf950

Please sign in to comment.