skills/ballee/production-database-query/SKILL.md
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, checking RLS behavior, applying hotfix migrations, or triggering Meteor sync
npx skillsauth add javeedishaq/ai-workflow-orchestrator production-database-queryInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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.mdtools
# Test Patterns Testing patterns for reliable, maintainable, and fast tests. > **Template Usage:** Customize for your test framework (Vitest, Jest, Playwright, etc.) and assertion library. ## Test Structure ```typescript // user.test.ts import { describe, it, expect, beforeEach, afterEach } from 'vitest'; import { userService } from '@/services/user.service'; import { createTestUser, cleanupTestData } from '@/tests/helpers'; describe('UserService', () => { let testUserId: string; befor
tools
# State Management Patterns Client-side state management patterns for modern applications. > **Template Usage:** Customize for your state library (React Query, Zustand, Jotai, Redux, etc.). ## State Categories | Type | Description | Solution | |------|-------------|----------| | **Server State** | Data from API/database | React Query, SWR | | **Client State** | UI state, user preferences | Zustand, Jotai, useState | | **Form State** | Form inputs, validation | React Hook Form, Formik | | **U
development
# Service Patterns Service layer patterns for clean architecture with proper error handling, logging, and type safety. > **Template Usage:** Customize for your ORM (Prisma, Drizzle, TypeORM, etc.) and logging solution. ## Result Type Pattern Never throw exceptions from services. Always return a Result type. ```typescript // lib/result.ts export type Result<T, E = Error> = | { success: true; data: T } | { success: false; error: E }; export function ok<T>(data: T): Result<T, never> { r
testing
# Row-Level Security Patterns Database security patterns for multi-tenant and user-scoped data. > **Template Usage:** Customize for your database (PostgreSQL, Supabase, etc.) and auth system. ## RLS Fundamentals ### Enable RLS on Tables ```sql -- Enable RLS (required before policies take effect) ALTER TABLE users ENABLE ROW LEVEL SECURITY; ALTER TABLE posts ENABLE ROW LEVEL SECURITY; ALTER TABLE comments ENABLE ROW LEVEL SECURITY; -- Force RLS for table owners too (recommended) ALTER TABLE