refactor: apply env variable pattern to all sexy scripts
Extended environment variable usage to export scripts and simplified the env loading pattern across all scripts. Changes: - sexy/db/export: now uses $DB_USER and $SEXY_DB_NAME - sexy/export/all: now uses $DB_USER and $SEXY_DB_NAME - All scripts: changed from 'set -a && source .env && set +a' to 'export $(cat .env | xargs)' for cleaner, more concise syntax This ensures consistent variable usage across all import/export scripts and makes them work correctly in all environments.
This commit is contained in:
14
arty.yml
14
arty.yml
@@ -70,9 +70,10 @@ scripts:
|
|||||||
# Database export scripts for sexy.pivoine.art
|
# Database export scripts for sexy.pivoine.art
|
||||||
# Export PostgreSQL database schema and data with DROP IF EXISTS statements
|
# Export PostgreSQL database schema and data with DROP IF EXISTS statements
|
||||||
sexy/db/export: |
|
sexy/db/export: |
|
||||||
|
export $(cat .env | xargs) &&
|
||||||
docker exec core_postgres pg_dump \
|
docker exec core_postgres pg_dump \
|
||||||
-U sexy \
|
-U $DB_USER \
|
||||||
-d sexy \
|
-d $SEXY_DB_NAME \
|
||||||
--no-owner \
|
--no-owner \
|
||||||
--no-acl \
|
--no-acl \
|
||||||
--clean \
|
--clean \
|
||||||
@@ -89,10 +90,11 @@ scripts:
|
|||||||
|
|
||||||
# Combined export: both database and schema
|
# Combined export: both database and schema
|
||||||
sexy/export/all: |
|
sexy/export/all: |
|
||||||
|
export $(cat .env | xargs) &&
|
||||||
echo "Exporting database..." &&
|
echo "Exporting database..." &&
|
||||||
docker exec core_postgres pg_dump \
|
docker exec core_postgres pg_dump \
|
||||||
-U sexy \
|
-U $DB_USER \
|
||||||
-d sexy \
|
-d $SEXY_DB_NAME \
|
||||||
--no-owner \
|
--no-owner \
|
||||||
--no-acl \
|
--no-acl \
|
||||||
--clean \
|
--clean \
|
||||||
@@ -109,7 +111,7 @@ scripts:
|
|||||||
# Import PostgreSQL database from SQL dump
|
# Import PostgreSQL database from SQL dump
|
||||||
# WARNING: This will DROP existing tables if they exist (uses --clean --if-exists)
|
# WARNING: This will DROP existing tables if they exist (uses --clean --if-exists)
|
||||||
sexy/db/import: |
|
sexy/db/import: |
|
||||||
set -a && source .env && set +a &&
|
export $(cat .env | xargs) &&
|
||||||
echo "⚠️ WARNING: This will replace the current database!" &&
|
echo "⚠️ WARNING: This will replace the current database!" &&
|
||||||
echo "Make sure core_postgres container is running..." &&
|
echo "Make sure core_postgres container is running..." &&
|
||||||
docker exec -i core_postgres psql -U $DB_USER -d $SEXY_DB_NAME < ~/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 &&
|
||||||
@@ -133,7 +135,7 @@ scripts:
|
|||||||
# Step 1: Import database (drops/recreates all tables)
|
# Step 1: Import database (drops/recreates all tables)
|
||||||
# Step 2: Apply schema (updates Directus metadata)
|
# Step 2: Apply schema (updates Directus metadata)
|
||||||
sexy/import/all: |
|
sexy/import/all: |
|
||||||
set -a && source .env && set +a &&
|
export $(cat .env | xargs) &&
|
||||||
echo "⚠️ WARNING: This will completely replace the database and schema!" &&
|
echo "⚠️ WARNING: This will completely replace the database and schema!" &&
|
||||||
echo "Importing database..." &&
|
echo "Importing database..." &&
|
||||||
docker exec -i core_postgres psql -U $DB_USER -d $SEXY_DB_NAME < ~/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 &&
|
||||||
|
|||||||
Reference in New Issue
Block a user