π₯π₯π₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.
TypeScript boardsbug-trackerdjangodockerganttissue-trackerjirajira-alternativekanbanlinearpostgresqlproduct-managementproject-managementproject-planningpythonreactredistypesciptvitework-management
dev: migration check (#3440)
Nikhil512ad83c0853
diff --git a/apiserver/Dockerfile.dev b/apiserver/Dockerfile.devindex cb2d1ca280..bd6684fd5f 100644--- a/apiserver/Dockerfile.dev+++ b/apiserver/Dockerfile.dev@@ -33,15 +33,10 @@ RUN pip install -r requirements/local.txt --compile --no-cache-dirRUN addgroup -S plane && \adduser -S captain -G plane-RUN chown captain.plane /code+COPY . .-USER captain--# Add in Django deps and generate Django's static files--USER root--# RUN chmod +x ./bin/takeoff ./bin/worker ./bin/beat+RUN chown -R captain.plane /code+RUN chmod -R +x /code/binRUN chmod -R 777 /codeUSER captaindiff --git a/apiserver/bin/beat b/apiserver/bin/beatold mode 100644new mode 100755index 45d357442a..3a9602a9ee--- a/apiserver/bin/beat+++ b/apiserver/bin/beat@@ -2,4 +2,7 @@set -epython manage.py wait_for_db+# Wait for migrations+python manage.py wait_for_migrations+# Run the processescelery -A plane beat -l info\ No newline at end of filediff --git a/apiserver/bin/takeoff b/apiserver/bin/takeoffindex 0ec2e495ca..efea53f874 100755--- a/apiserver/bin/takeoff+++ b/apiserver/bin/takeoff@@ -1,7 +1,8 @@#!/bin/bashset -epython manage.py wait_for_db-python manage.py migrate+# Wait for migrations+python manage.py wait_for_migrations# Create the default bucket#!/bin/bashdiff --git a/apiserver/bin/takeoff.local b/apiserver/bin/takeoff.localindex b89c208741..8f62370ecf 100755--- a/apiserver/bin/takeoff.local+++ b/apiserver/bin/takeoff.local@@ -1,7 +1,8 @@#!/bin/bashset -epython manage.py wait_for_db-python manage.py migrate+# Wait for migrations+python manage.py wait_for_migrations# Create the default bucket#!/bin/bashdiff --git a/apiserver/bin/worker b/apiserver/bin/workerindex 9d2da1254d..a70b5f77cf 100755--- a/apiserver/bin/worker+++ b/apiserver/bin/worker@@ -2,4 +2,7 @@set -epython manage.py wait_for_db+# Wait for migrations+python manage.py wait_for_migrations+# Run the processescelery -A plane worker -l info\ No newline at end of filediff --git a/apiserver/plane/db/management/commands/wait_for_migrations.py b/apiserver/plane/db/management/commands/wait_for_migrations.pynew file mode 100644index 0000000000..51f2cf3393--- /dev/null+++ b/apiserver/plane/db/management/commands/wait_for_migrations.py@@ -0,0 +1,21 @@+# wait_for_migrations.py+import time+from django.core.management.base import BaseCommand+from django.db.migrations.executor import MigrationExecutor+from django.db import connections, DEFAULT_DB_ALIAS++class Command(BaseCommand):+ help = 'Wait for database migrations to complete before starting Celery worker/beat'++ def handle(self, *args, **kwargs):+ while self._pending_migrations():+ self.stdout.write("Waiting for database migrations to complete...")+ time.sleep(10) # wait for 10 seconds before checking again++ self.stdout.write(self.style.SUCCESS("No migrations Pending. Starting processes ..."))++ def _pending_migrations(self):+ connection = connections[DEFAULT_DB_ALIAS]+ executor = MigrationExecutor(connection)+ targets = executor.loader.graph.leaf_nodes()+ return bool(executor.migration_plan(targets))diff --git a/deploy/selfhost/docker-compose.yml b/deploy/selfhost/docker-compose.ymlindex e42f53c7aa..b223e722ab 100644--- a/deploy/selfhost/docker-compose.yml+++ b/deploy/selfhost/docker-compose.yml@@ -122,6 +122,18 @@ services:- plane-db- plane-redis+ migrator:+ <<: *app-env+ image: ${DOCKERHUB_USER:-makeplane}/plane-backend:${APP_RELEASE:-latest}+ pull_policy: ${PULL_POLICY:-always}+ restart: no+ command: >+ sh -c "python manage.py wait_for_db &&+ python manage.py migrate"+ depends_on:+ - plane-db+ - plane-redis+plane-db:<<: *app-envimage: postgres:15.2-alpinediff --git a/docker-compose-local.yml b/docker-compose-local.ymlindex b0fb9da245..a2e518708d 100644--- a/docker-compose-local.yml+++ b/docker-compose-local.yml@@ -86,7 +86,7 @@ services:- dev_envvolumes:- ./apiserver:/code- # command: /bin/sh -c "python manage.py migrate && python manage.py runserver 0.0.0.0:8000 --settings=plane.settings.local"+ command: ./bin/takeoff.localenv_file:- ./apiserver/.envdepends_on:@@ -104,7 +104,7 @@ services:- dev_envvolumes:- ./apiserver:/code- command: /bin/sh -c "celery -A plane worker -l info"+ command: ./bin/workerenv_file:- ./apiserver/.envdepends_on:@@ -123,7 +123,7 @@ services:- dev_envvolumes:- ./apiserver:/code- command: /bin/sh -c "celery -A plane beat -l info"+ command: ./bin/beatenv_file:- ./apiserver/.envdepends_on:@@ -131,6 +131,26 @@ services:- plane-db- plane-redis+ migrator:+ build:+ context: ./apiserver+ dockerfile: Dockerfile.dev+ args:+ DOCKER_BUILDKIT: 1+ restart: no+ networks:+ - dev_env+ volumes:+ - ./apiserver:/code+ command: >+ sh -c "python manage.py wait_for_db --settings=plane.settings.local &&+ python manage.py migrate --settings=plane.settings.local"+ env_file:+ - ./apiserver/.env+ depends_on:+ - plane-db+ - plane-redis+proxy:build:context: ./nginx