Skip to content

Commit

Permalink
Merge pull request #668 from DFE-Digital/init-container
Browse files Browse the repository at this point in the history
Add entrypoint file to consolidate the migration scripts into 1
  • Loading branch information
DrizzlyOwl authored Jan 7, 2025
2 parents e692d32 + 1a3ca94 commit d20c6d2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ RUN ["mkdir", "/sql"]
RUN ["dotnet", "tool", "install", "--global", "dotnet-ef"]
RUN ["dotnet", "ef", "migrations", "bundle", "-r", "linux-x64", "--configuration", "Release", "-p", "TramsDataApi", "--context", "TramsDataApi.DatabaseModels.LegacyTramsDbContext", "--no-build", "-o", "/sql/migratelegacydb"]
RUN ["dotnet", "ef", "migrations", "bundle", "-r", "linux-x64", "--configuration", "Release", "-p", "TramsDataApi", "--context", "TramsDataApi.DatabaseModels.TramsDbContext", "--no-build", "-o", "/sql/migratedb"]
COPY ./script/init-docker-entrypoint.sh /sql/entrypoint.sh
RUN ["chmod", "+x", "/sql/entrypoint.sh"]

# ==============================================
# Entity Framework: Migration Runner
Expand Down
19 changes: 19 additions & 0 deletions script/init-docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# exit on failures
set -e
set -o pipefail

while getopts "c" opt; do
case $opt in
c)
CONNECTION_STRING=$opt
;;
*)
usage
;;
esac
done

/sql/migratedb -v --connection "$CONNECTION_STRING"
/sql/migratelegacydb -v --connection "$CONNECTION_STRING"

0 comments on commit d20c6d2

Please sign in to comment.