21 lines
850 B
Bash
Executable File
21 lines
850 B
Bash
Executable File
#!/bin/bash
|
|
# Usage: SSH_PASS=<password> bash db/01-load-schema.sh
|
|
# Or: configure SSH key auth first, then just: bash db/01-load-schema.sh
|
|
set -e
|
|
|
|
SERVER="setia@ims.setia.com.my"
|
|
PORT=9321
|
|
|
|
echo "==> Copying schema files to server..."
|
|
scp -P "$PORT" db/schema.sql db/rls.sql "$SERVER:/tmp/"
|
|
|
|
echo "==> Loading schema on server..."
|
|
ssh -p "$PORT" "$SERVER" "sudo -u postgres psql -d ims -f /tmp/schema.sql && sudo -u postgres psql -d ims -f /tmp/rls.sql"
|
|
|
|
echo "==> Cleaning up temp files..."
|
|
ssh -p "$PORT" "$SERVER" "rm /tmp/schema.sql /tmp/rls.sql"
|
|
|
|
echo "==> Schema loaded. Verifying table count..."
|
|
ssh -p "$PORT" "$SERVER" "sudo -u postgres psql -d ims -c \"SELECT count(*) AS table_count FROM information_schema.tables WHERE table_schema = 'public' AND table_type = 'BASE TABLE';\""
|
|
# Expected: 14 tables (13 original + password_reset_tokens)
|