Skip to content

Commit ceb70d7

Browse files
chore: Move migrations to heroku release step (#7574)
1 parent 76784dd commit ceb70d7

File tree

5 files changed

+6
-9
lines changed

5 files changed

+6
-9
lines changed

Diff for: Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
release: python manage.py prepare_db && python manage.py db upgrade
12
web: sh ./scripts/heroku.sh

Diff for: kubernetes/run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ echo "[LOG] Using redis: ${REDIS_URL}"
55
if [ "$DEPLOYMENT" == "api" ]
66
then
77
echo "[LOG] Preparing database"
8-
python manage.py prepare_kubernetes_db
8+
python manage.py prepare_db
99
echo "[LOG] Running migrations"
1010
python manage.py db upgrade
1111
echo "[LOG] Starting gunicorn on port 8080"

Diff for: manage.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def fix_event_and_speaker_images():
7575

7676
@manager.command
7777
def fix_digit_identifier():
78-
events = Event.query.filter(Event.identifier.op('~')('^[0-9\.]+$')).all()
78+
events = Event.query.filter(Event.identifier.op('~')(r'^[0-9\.]+$')).all()
7979
for event in events:
8080
event.identifier = get_new_event_identifier()
8181
db.session.add(event)
@@ -147,7 +147,7 @@ def initialize_db(credentials):
147147

148148

149149
@manager.command
150-
def prepare_kubernetes_db(credentials='[email protected]:fossasia'):
150+
def prepare_db(credentials='[email protected]:fossasia'):
151151
with app.app_context():
152152
initialize_db(credentials)
153153

Diff for: scripts/container_start.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if [ "$DEPLOYMENT" == "api" ]
99
then
1010
echo "[LOG] Waiting for Database" && ./scripts/wait-for.sh ${POSTGRES_HOST}:5432 --timeout=60 -- echo "[LOG] Database Up"
1111
echo "[LOG] Preparing database"
12-
python manage.py prepare_kubernetes_db
12+
python manage.py prepare_db
1313
echo "[LOG] Running migrations"
1414
python manage.py db upgrade
1515
export PORT=${PORT:-8080}

Diff for: scripts/heroku.sh

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
#!/bin/bash
2-
python3 manage.py db upgrade
3-
python3 populate_db.py &
4-
export INTEGRATE_SOCKETIO=false
5-
# socketio has problems with celery "blocking" tasks
6-
# also socketio is not used in a celery task so no problem to turn it off
72
chmod -R 0777 ./static
83
./scripts/l10n.sh generate &
4+
touch .env
95
celery -A app.instance.celery worker --loglevel=info -c 1 &
106
if [ "$APP_CONFIG" = "config.DevelopmentConfig" ]; then
117
python manage.py runserver -h 0.0.0.0 -p ${PORT:-8000} --no-reload

0 commit comments

Comments
 (0)