From dee16f7321fbc77a8648fa8b67b3f56dbe3b90cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Tue, 28 Oct 2025 23:19:00 +0100 Subject: [PATCH] fix: use environment variables in sexy import scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed hardcoded database credentials to use environment variables: - `-U sexy` → `-U ${DB_USER}` - `-d sexy` → `-d ${SEXY_DB_NAME}` Also added missing interactive confirmation prompt to sexy/import/all script. This fixes the script error on VPS where: - VPS uses: DB_USER=valknar, SEXY_DB_NAME=directus - Local dev uses: DB_USER=sexy, SEXY_DB_NAME=sexy (or directus) The scripts now work correctly in both environments by reading the appropriate values from .env files via arty's environment system. --- arty.yml | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/arty.yml b/arty.yml index d0b6584..5b25a21 100644 --- a/arty.yml +++ b/arty.yml @@ -111,7 +111,7 @@ scripts: sexy/db/import: | echo "⚠️ WARNING: This will replace the current database!" && echo "Make sure core_postgres container is running..." && - docker exec -i core_postgres psql -U sexy -d sexy < ~/Projects/docker-compose/sexy/directus.sql && + docker exec -i core_postgres psql -U ${DB_USER} -d ${SEXY_DB_NAME} < ~/Projects/docker-compose/sexy/directus.sql && echo "✓ Database imported from ~/Projects/docker-compose/sexy/directus.sql" && echo "Restarting Directus API..." && docker restart sexy_api && @@ -133,16 +133,21 @@ scripts: # Step 2: Apply schema (updates Directus metadata) sexy/import/all: | echo "⚠️ WARNING: This will completely replace the database and schema!" && - echo "Importing database..." && - docker exec -i core_postgres psql -U sexy -d sexy < ~/Projects/docker-compose/sexy/directus.sql && - echo "✓ Database imported" && - echo "Applying Directus schema..." && - docker cp ~/Projects/docker-compose/sexy/schema.yaml sexy_api:/directus/schema.yaml && - docker exec sexy_api npx directus schema apply --yes /directus/schema.yaml && - echo "✓ Schema applied" && - echo "Restarting Directus API..." && - docker restart sexy_api && - echo "✓✓✓ Complete import finished successfully!" + read -p "Are you sure? Type 'yes' to continue: " confirm && + if [ "$confirm" = "yes" ]; then + echo "Importing database..." && + docker exec -i core_postgres psql -U ${DB_USER} -d ${SEXY_DB_NAME} < ~/Projects/docker-compose/sexy/directus.sql && + echo "✓ Database imported" && + echo "Applying Directus schema..." && + docker cp ~/Projects/docker-compose/sexy/schema.yaml sexy_api:/directus/schema.yaml && + docker exec sexy_api npx directus schema apply --yes /directus/schema.yaml && + echo "✓ Schema applied" && + echo "Restarting Directus API..." && + docker restart sexy_api && + echo "✓✓✓ Complete import finished successfully!"; + else + echo "Import cancelled."; + fi sexy/uploads/export: | rm -rf sexy/uploads