forked from bcgov/eagle-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_migration.sh
More file actions
executable file
·24 lines (22 loc) · 848 Bytes
/
run_migration.sh
File metadata and controls
executable file
·24 lines (22 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh
[ "${VERBOSE:-}" != true ]|| set -xe
DATABASE_JSON=$(cat << EOF
{
"defaultEnv": "local",
"local": {
"driver": "mongodb",
"database": "epic",
$([ "$MONGODB_ADMIN_USER" ] && echo "\"user\"":"\"$MONGODB_ADMIN_USER\"",)
$([ "$MONGODB_ADMIN_PASSWORD" ] && echo "\"password\"":"\"$MONGODB_ADMIN_PASSWORD\"",)
"host": $([ "$MONGODB_SERVICE_HOST" ] && echo "\"$MONGODB_SERVICE_HOST\"", || echo "\"localhost\"",)
$([ "$MONGODB_AUTHSOURCE" ] && echo "\"authSource\"":"\"$MONGODB_AUTHSOURCE\"",)
"port": $([ "$MONGODB_PORT" ] && echo "\"$MONGODB_PORT\"", || echo "\"27017\"")
}
}
EOF
)
echo "$DATABASE_JSON" > database_migration.json
cat ./database_migration.json
echo "Migration starting..."
node ./node_modules/db-migrate/bin/db-migrate up --config database_migration.json --env local
echo "Migration completed"