From ddf70e38fb78c643c92ee0787eb0242f3663b336 Mon Sep 17 00:00:00 2001 From: ssorin Date: Fri, 20 Dec 2024 16:26:54 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB(dashboard)=20?= =?UTF-8?q?add=20bootstrap=20and=20reset=20commands=20for=20dashboard=20se?= =?UTF-8?q?tup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce `bootstrap-dashboard` and `reset-dashboard-db` commands in the Makefile to streamline project setup and database resetting. Update the dashboard README with corresponding instructions for better developer onboarding. --- Makefile | 15 +++++++++++++++ src/dashboard/readme.md | 20 +++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index aa2d1a58..49f6c77e 100644 --- a/Makefile +++ b/Makefile @@ -72,6 +72,12 @@ bootstrap: \ seed-api .PHONY: bootstrap +bootstrap-dashboard: ## bootstrap the dashboard project for development +bootstrap-dashboard: \ + build-dashboard \ + reset-dashboard-db +.PHONY: bootstrap-dashboard + build: ## build services image $(COMPOSE) build .PHONY: build @@ -221,6 +227,8 @@ create-prefect-db: ## create prefect database .PHONY: create-prefect-db create-dashboard-db: ## create dashboard database + @echo "Running dashboard service database engineā€¦" + @$(COMPOSE_UP) --wait postgresql @echo "Creating dashboard service databaseā€¦" @$(COMPOSE) exec postgresql bash -c 'psql "postgresql://$${POSTGRES_USER}:$${POSTGRES_PASSWORD}@$${QUALICHARGE_DB_HOST}:$${QUALICHARGE_DB_PORT}/postgres" -c "create database \"$${DASHBOARD_DB_NAME}\";"' || echo "Duly noted, skipping database creation." .PHONY: create-dashboard-db @@ -329,6 +337,13 @@ reset-db: ## Reset the PostgreSQL database $(MAKE) seed-dashboard .PHONY: reset-db +reset-dashboard-db: ## Reset the PostgreSQL dashboard database + $(MAKE) create-dashboard-db + $(MAKE) migrate-dashboard + $(MAKE) create-dashboard-superuser + $(MAKE) seed-dashboard +.PHONY: reset-dashboard-db + seed-api: ## seed the API database (static data) seed-api: run zcat data/irve-statique.json.gz | \ diff --git a/src/dashboard/readme.md b/src/dashboard/readme.md index 1e64ff88..92b2f5d3 100644 --- a/src/dashboard/readme.md +++ b/src/dashboard/readme.md @@ -15,13 +15,20 @@ The qualicharge dashboard is available from the url: ## Useful commands -Perform a Django migration *(manage.py migrate)* : +Bootstrap dashboard project: + +``` +make bootstrap-dashboard +make run-dashboard +``` + +Perform a Django migration *(manage.py migrate)*: ``` make migrate-dashboard-db ``` -Create superuser. +Create superuser: You can connect with **username: admin** / **password: admin**. *(The credentials are defined in env.d/dashboard.)* @@ -30,12 +37,19 @@ You can connect with **username: admin** / **password: admin**. make create-dashboard-superuser ``` -Display dashboard logs +Display dashboard logs: ``` make logs-dashboard ``` +Reset dashboard db: + +``` +make drop-dashboard-db +make reset-dashboard-db +``` + ## Project specific naming convention For each Django application, the application config label