♻️(yhub) maintain database schema using npm run init-db

The yhub database schema have new update and will probably be modified
in the future. We don't want to maintain this sql schema in the Docs
repo, we want to reuse what is directly made in the yhub project. For
this we reuse the existing bin/init-db.js script
This commit is contained in:
Manuel Raynaud
2026-09-11 10:53:25 +02:00
committed by Anthony LC
parent 9cdaa1fb2e
commit 844ad00a12
6 changed files with 48 additions and 24 deletions
+15
View File
@@ -101,6 +101,7 @@ pre-bootstrap: \
post-bootstrap: \
migrate \
migrate-yhub \
demo \
back-i18n-compile \
mails-install \
@@ -332,6 +333,20 @@ migrate: ## run django migrations for the impress project.
@$(MANAGE) migrate
.PHONY: migrate
# Runs the DDL script yhub ships (`bin/init-db.js`, wrapped as `npm run
# init-db`): it creates the yhub database when missing, then every table the
# installed @y/hub version needs. yhub never runs DDL from the server or the
# worker, so this is what applies a schema change after an upgrade.
# Both stores are started because the script also creates the valkey worker
# stream and connects to it whenever REDIS is set. Re-running is safe and
# expected; on an existing stream it logs a harmless `BUSYGROUP` error and
# still exits 0, since the server creates that stream at startup anyway.
migrate-yhub: ## create or upgrade the collaboration server (yhub) schema.
@echo "$(BOLD)Running yhub migrations$(RESET)"
@$(COMPOSE) up -d yhub-postgres yhub-valkey
@$(COMPOSE_RUN) --no-deps yhub npm run init-db
.PHONY: migrate-yhub
superuser: ## Create an admin superuser with password "admin"
@echo "$(BOLD)Creating a Django superuser$(RESET)"
@$(MANAGE) createsuperuser --email admin@example.com --password admin