feat: god-mode expansion with schema management, site provisioning, and schema-as-code
- Added frontend godMode client library for all admin pages - Created schema management endpoints (create/edit collections, fields, relations) - Built automated site provisioning (creates site + homepage + navigation + forms) - Implemented schema-as-code with start.sh auto-migration script - Added FORCE_FRESH_INSTALL mode for database wipes - Integrated work log, error log, and queue management via god-mode - All admin pages can now use god-mode for seamless operations
This commit is contained in:
83
start.sh
Executable file
83
start.sh
Executable file
@@ -0,0 +1,83 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
echo "🚀 Spark Platform - Starting Directus with Schema-as-Code..."
|
||||
|
||||
# === Configuration ===
|
||||
DB_READY=false
|
||||
MAX_RETRIES=30
|
||||
RETRY_COUNT=0
|
||||
|
||||
# === Wait for PostgreSQL ===
|
||||
echo "📡 Waiting for PostgreSQL to be ready..."
|
||||
until [ $DB_READY = true ] || [ $RETRY_COUNT -eq $MAX_RETRIES ]; do
|
||||
if PGPASSWORD=$DB_PASSWORD psql -h $DB_HOST -U $DB_USER -d $DB_DATABASE -c '\q' 2>/dev/null; then
|
||||
DB_READY=true
|
||||
echo "✅ PostgreSQL is ready"
|
||||
else
|
||||
RETRY_COUNT=$((RETRY_COUNT + 1))
|
||||
echo "⏳ Waiting for PostgreSQL... ($RETRY_COUNT/$MAX_RETRIES)"
|
||||
sleep 2
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $DB_READY = false ]; then
|
||||
echo "❌ PostgreSQL failed to start after $MAX_RETRIES attempts"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# === Fresh Install Mode ===
|
||||
if [ "$FORCE_FRESH_INSTALL" = "true" ]; then
|
||||
echo ""
|
||||
echo "⚠️ ============================================"
|
||||
echo "⚠️ FORCE_FRESH_INSTALL MODE ACTIVATED"
|
||||
echo "⚠️ Wiping entire database in 5 seconds..."
|
||||
echo "⚠️ Press Ctrl+C to cancel!"
|
||||
echo "⚠️ ============================================"
|
||||
sleep 5
|
||||
|
||||
echo "🗑️ Dropping public schema..."
|
||||
PGPASSWORD=$DB_PASSWORD psql -h $DB_HOST -U $DB_USER -d $DB_DATABASE <<-EOSQL
|
||||
DROP SCHEMA IF EXISTS public CASCADE;
|
||||
CREATE SCHEMA public;
|
||||
GRANT ALL ON SCHEMA public TO $DB_USER;
|
||||
GRANT ALL ON SCHEMA public TO public;
|
||||
COMMENT ON SCHEMA public IS 'Recreated by FORCE_FRESH_INSTALL';
|
||||
EOSQL
|
||||
|
||||
echo "✅ Database wiped clean - ready for fresh install"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# === Bootstrap Directus ===
|
||||
echo "📦 Bootstrapping Directus..."
|
||||
npx directus bootstrap
|
||||
|
||||
# === Apply Schema from Code ===
|
||||
if [ -f "/directus/schema.yaml" ]; then
|
||||
echo "🔄 Applying schema from schema.yaml..."
|
||||
npx directus schema apply /directus/schema.yaml --yes
|
||||
echo "✅ Schema applied from code"
|
||||
elif [ -f "/directus/complete_schema.sql" ]; then
|
||||
echo "🔄 Applying schema from complete_schema.sql..."
|
||||
PGPASSWORD=$DB_PASSWORD psql -h $DB_HOST -U $DB_USER -d $DB_DATABASE < /directus/complete_schema.sql
|
||||
echo "✅ SQL schema applied"
|
||||
else
|
||||
echo "⚠️ No schema.yaml or complete_schema.sql found"
|
||||
echo "ℹ️ Directus will start with empty schema"
|
||||
fi
|
||||
|
||||
# === Import Extensions ===
|
||||
if [ -d "/directus/extensions" ]; then
|
||||
echo "🔌 Loading extensions..."
|
||||
EXTENSION_COUNT=$(find /directus/extensions -name "package.json" | wc -l)
|
||||
echo "📦 Found $EXTENSION_COUNT extensions"
|
||||
fi
|
||||
|
||||
# === Start Directus ===
|
||||
echo ""
|
||||
echo "✅ Initialization complete"
|
||||
echo "🚀 Starting Directus server..."
|
||||
echo ""
|
||||
|
||||
npx directus start
|
||||
Reference in New Issue
Block a user