Query Ballee production and staging databases safely using .env.local credentials (with 1Password fallback); use when debugging production/staging data, verifying data exists, investigating bugs,...
Query the Ballee production and staging databases safely using credentials from .env.local (with automatic 1Password fallback and caching).
Use this skill when:
Ballee uses two separate Supabase databases for production and staging environments.
| Environment | Project Name | Project Reference ID | URL | Region |
|---|---|---|---|---|
| Production | ballee |
csjruhqyqzzqxnfeyiaf |
https://csjruhqyqzzqxnfeyiaf.supabase.co |
Central EU (Frankfurt) |
| Staging | ballee-staging |
hxpcknyqswetsqmqmeep |
https://hxpcknyqswetsqmqmeep.supabase.co |
Central EU (Frankfurt) |
Important: Use aws-1-eu-central-1 (not aws-0) for reliable connections.
Production:
aws-1-eu-central-1.pooler.supabase.com:5432postgres.csjruhqyqzzqxnfeyiafStaging:
aws-1-eu-central-1.pooler.supabase.com:5432postgres.hxpcknyqswetsqmqmeepCredentials are stored in apps/web/.env.local:
| Variable | Environment | Description |
|---|---|---|
SUPABASE_DB_PASSWORD_PROD |
Production | Production database password |
SUPABASE_DB_PASSWORD_STAGING |
Staging | Staging database password |
If environment variables are not set, credentials will be fetched from 1Password and cached to .env.local:
| Credential | 1Password Item ID | 1Password Field | Environment |
|---|---|---|---|
| Production DB Password | kuyspxxlyi2mxg7nfeb6dm3pje |
notesPlain |
Production |
| Staging DB Password | rkzjnr5ffy5u6iojnsq3clnmia |
notesPlain |
Staging |
| Supabase Access Token | uipc6jse6q32hu3nyfh6qmssoq |
password |
Both |
psql).env.local OR 1Password CLI installed and authenticated (op whoami)# Load password from .env.local (or fetch from 1Password and cache)
source apps/web/.env.local 2>/dev/null
if [ -z "$SUPABASE_DB_PASSWORD_PROD" ]; then
SUPABASE_DB_PASSWORD_PROD="$(op item get kuyspxxlyi2mxg7nfeb6dm3pje --fields notesPlain --reveal)"
echo "SUPABASE_DB_PASSWORD_PROD=$SUPABASE_DB_PASSWORD_PROD" >> apps/web/.env.local
fi
# Connect to production
PGPASSWORD="$SUPABASE_DB_PASSWORD_PROD" psql \
"postgresql://postgres.csjruhqyqzzqxnfeyiaf@aws-1-eu-central-1.pooler.supabase.com:5432/postgres"
# Execute single query on production
PGPASSWORD="$SUPABASE_DB_PASSWORD_PROD" psql \
"postgresql://postgres.csjruhqyqzzqxnfeyiaf@aws-1-eu-central-1.pooler.supabase.com:5432/postgres" \
-c "SELECT * FROM events LIMIT 5;"
# Apply migration to production
PGPASSWORD="$SUPABASE_DB_PASSWORD_PROD" psql \
"postgresql://postgres.csjruhqyqzzqxnfeyiaf@aws-1-eu-central-1.pooler.supabase.com:5432/postgres" \
-f apps/web/supabase/migrations/YYYYMMDDHHMMSS_description.sql
# Load password from .env.local (or fetch from 1Password and cache)
source apps/web/.env.local 2>/dev/null
if [ -z "$SUPABASE_DB_PASSWORD_STAGING" ]; then
SUPABASE_DB_PASSWORD_STAGING="$(op item get rkzjnr5ffy5u6iojnsq3clnmia --fields notesPlain --reveal)"
echo "SUPABASE_DB_PASSWORD_STAGING=$SUPABASE_DB_PASSWORD_STAGING" >> apps/web/.env.local
fi
# Connect to staging
PGPASSWORD="$SUPABASE_DB_PASSWORD_STAGING" psql \
"postgresql://postgres.hxpcknyqswetsqmqmeep@aws-1-eu-central-1.pooler.supabase.com:5432/postgres"
# Execute single query on staging
PGPASSWORD="$SUPABASE_DB_PASSWORD_STAGING" psql \
"postgresql://postgres.hxpcknyqswetsqmqmeep@aws-1-eu-central-1.pooler.supabase.com:5432/postgres" \
-c "SELECT * FROM events LIMIT 5;"
# Apply migration to staging
PGPASSWORD="$SUPABASE_DB_PASSWORD_STAGING" psql \
"postgresql://postgres.hxpcknyqswetsqmqmeep@aws-1-eu-central-1.pooler.supabase.com:5432/postgres" \
-f apps/web/supabase/migrations/YYYYMMDDHHMMSS_description.sql
Production: https://supabase.com/dashboard/project/csjruhqyqzzqxnfeyiaf/sql/new
Staging: https://supabase.com/dashboard/project/hxpcknyqswetsqmqmeep/sql/new
SELECT
ho.id,
ho.order_number,
ho.status,
ho.dancer_approved_at,
ho.estimated_total,
ho.created_at,
cr.role_name,
e.title as event_title
FROM hire_orders ho
LEFT JOIN cast_roles cr ON ho.cast_role_id = cr.id
LEFT JOIN events e ON ho.event_id = e.id
WHERE ho.event_id = 'event-uuid'
ORDER BY ho.created_at DESC;
SELECT
ep.id,
ep.status,
ep.created_at,
p.first_name,
p.last_name,
p.email
FROM event_participants ep
LEFT JOIN profiles p ON ep.user_id = p.id
WHERE ep.event_id = 'event-uuid'
ORDER BY ep.created_at DESC;
SELECT
ca.id,
ca.assignment_status,
ca.rate,
cr.role_name,
p.first_name,
p.last_name
FROM cast_assignments ca
LEFT JOIN cast_roles cr ON ca.cast_role_id = cr.id
LEFT JOIN profiles p ON ca.user_id = p.id
WHERE ca.event_id = 'event-uuid';
SELECT schemaname, tablename, policyname, permissive, roles, cmd, qual
FROM pg_policies
WHERE tablename = 'hire_orders';
SELECT version, name, statements
FROM supabase_migrations.schema_migrations
ORDER BY version DESC
LIMIT 20;
After applying a migration manually, record it in the tracking table:
INSERT INTO supabase_migrations.schema_migrations (version, name, statements)
VALUES ('YYYYMMDDHHMMSS', 'migration_name', ARRAY['SQL_STATEMENT'])
ON CONFLICT (version) DO NOTHING;
1Password not authenticated:
op signin
# Follow authentication flow
psql not installed:
brew install postgresql@16
Connection timeout / "Tenant or user not found":
aws-1-eu-central-1.pooler.supabase.com (not aws-0)LIMIT clause to avoid large result setsschema_migrationsThe Ballee legacy Meteor app uses a MongoDB database hosted on Zerion (zcloud.ws). This is used for syncing data from the old community app.
| Credential | 1Password Item | Description |
|---|---|---|
| MongoDB URL | Ballee Meteor MongoDB URL |
Full connection string with credentials |
| DB Username | root |
MongoDB admin user |
| DB Name | meteor |
Database name |
mongodb://root:<password>@mdb-p-0.ballee.db-eu2.zcloud.ws:60601,mdb-p-1.ballee.db-eu2.zcloud.ws:60602,mdb-p-2.ballee.db-eu2.zcloud.ws:60603/meteor?authSource=admin&ssl=true&tlsInsecure=true&replicaSet=mdb-p
# From 1Password
op read "op://Private/Ballee Meteor MongoDB URL/password"
For syncing data from MongoDB to Supabase staging, use the CLI tool:
# Set environment variables
export METEOR_SYNC_API_KEY="$(op read 'op://Private/Ballee Meteor Sync API Key/password')"
export STAGING_URL="https://ballee-git-feat-community-app-antoineschallers.vercel.app"
# Available commands
pnpm meteor:staging status # Check MongoDB connection
pnpm meteor:staging history # View sync history
pnpm meteor:staging trigger # Trigger full sync
pnpm meteor:staging trigger --type incremental
pnpm meteor:staging trigger --entity organization
pnpm meteor:staging logs <runId>
pnpm meteor:staging stats
| Variable | Environment | Description |
|---|---|---|
METEOR_MONGO_URL |
Preview/Production | Full MongoDB connection URL |
METEOR_SYNC_API_KEY |
Preview/Production | API key for sync endpoint auth |
apps/web/supabase/CLAUDE.md.claude/skills/production-database-query/scripts/sql-exec.sh.claude/skills/database-migration-manager/SKILL.mdscripts/meteor-sync/README.md