95f8e9a70b
Postgres en_US.utf8 collation sorts case-insensitively, breaking the lexicographic fractional indexing. Setting COLLATE "C" ensures pure byte-order sorting. Applied via setup-collation.sql in entrypoint after prisma db push. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
46 lines
1.2 KiB
Bash
46 lines
1.2 KiB
Bash
#!/bin/sh
|
|
set -e
|
|
|
|
echo "Waiting for database..."
|
|
MAX_RETRIES=30
|
|
RETRY=0
|
|
|
|
while [ $RETRY -lt $MAX_RETRIES ]; do
|
|
if npx prisma db push --skip-generate 2>&1; then
|
|
echo "Database schema synced successfully."
|
|
break
|
|
fi
|
|
RETRY=$((RETRY + 1))
|
|
echo "Database not ready (attempt $RETRY/$MAX_RETRIES), retrying in 3s..."
|
|
sleep 3
|
|
done
|
|
|
|
if [ $RETRY -ge $MAX_RETRIES ]; then
|
|
echo "ERROR: Could not connect to database after $MAX_RETRIES attempts."
|
|
exit 1
|
|
fi
|
|
|
|
echo "Applying position column collation fix..."
|
|
if psql "$DATABASE_URL" -f ./scripts/setup-collation.sql; then
|
|
echo "Collation fix applied successfully."
|
|
else
|
|
echo "WARNING: Failed to apply collation fix. Continuing anyway..."
|
|
fi
|
|
|
|
echo "Applying RLS policies..."
|
|
if psql "$DATABASE_URL" -f ./scripts/setup-rls.sql; then
|
|
echo "RLS policies applied successfully."
|
|
else
|
|
echo "WARNING: Failed to apply RLS policies. Continuing anyway..."
|
|
fi
|
|
|
|
echo "Applying full-text search indexes..."
|
|
if psql "$DATABASE_URL" -f ./scripts/setup-search.sql; then
|
|
echo "Search indexes applied successfully."
|
|
else
|
|
echo "WARNING: Failed to apply search indexes. Continuing anyway..."
|
|
fi
|
|
|
|
echo "Starting server..."
|
|
exec node server.js
|