forked from HHS/TANF-app
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/2729 remote migrations (#2779)
* add apply remote migrations script * add missing required env * rm migrate from gunicorn start * add required lib * add migrate command to pipeline * fix deps * rm message * tom's workaround * re-lock deps * remove commented migration lines * rm graphviz * catch exit status * add failing test migration * delete test migration * testing migration from local * rm test migration --------- Co-authored-by: Alexandra Pennington <[email protected]> Co-authored-by: raftmsohani <[email protected]>
- Loading branch information
1 parent
e9947f9
commit e247aa2
Showing
9 changed files
with
399 additions
and
349 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash | ||
|
||
app=${1} | ||
|
||
cd ./tdrs-backend | ||
|
||
echo "Install dependencies..." | ||
sudo apt install -y gcc | ||
sudo apt install -y libpq-dev python3-dev | ||
|
||
python -m venv ./env | ||
source ./env/bin/activate | ||
pip install --upgrade pip pipenv | ||
pipenv install --dev --system --deploy | ||
echo "Done." | ||
|
||
echo "Getting credentials..." | ||
guid=$(cf app --guid $app) | ||
app_vars=$(cf curl /v2/apps/$guid/env) | ||
|
||
db_creds=$(echo $app_vars | jq -r '.system_env_json.VCAP_SERVICES."aws-rds"[0].credentials') | ||
connection_str=$(echo $db_creds | jq -r '[.host, .port]' | jq -r 'join(":")') | ||
echo "Done." | ||
|
||
echo "Starting tunnel..." | ||
cf ssh -N -L 5432:$connection_str $app & | ||
sleep 5 | ||
echo "Done." | ||
|
||
echo "Setting up environment..." | ||
cp ./.env.example ./.env.ci | ||
|
||
vcap_services=$(echo $app_vars | jq -r '.system_env_json.VCAP_SERVICES') | ||
vcap_application=$(echo $app_vars | jq -rc '.application_env_json.VCAP_APPLICATION') | ||
|
||
# replace host env var | ||
fixed_vcap_services=$(echo $vcap_services | jq -rc '."aws-rds"[0].credentials.host="localhost"') | ||
|
||
echo "VCAP_SERVICES='$fixed_vcap_services'" >> .env.ci | ||
echo "VCAP_APPLICATION='$vcap_application'" >> .env.ci | ||
|
||
set -a | ||
source .env.ci | ||
export DJANGO_CONFIGURATION=Development | ||
export DJANGO_SETTINGS_MODULE=tdpservice.settings.cloudgov | ||
set +a | ||
echo "Done." | ||
|
||
echo "Applying migrations..." | ||
python manage.py migrate | ||
status=$? | ||
echo "Done." | ||
|
||
echo "Cleaning up..." | ||
deactivate | ||
kill $! | ||
rm ./.env.ci | ||
cd .. | ||
echo "Done." | ||
|
||
if [ $status -eq 0 ] | ||
then | ||
echo "Migrations applied successfully." | ||
exit 0 | ||
else | ||
echo "Migrations failed." | ||
exit $status | ||
fi |
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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