diff --git a/.trellis/spec/backend/database-guidelines.md b/.trellis/spec/backend/database-guidelines.md index a99ba1a..17d0cbc 100644 --- a/.trellis/spec/backend/database-guidelines.md +++ b/.trellis/spec/backend/database-guidelines.md @@ -9,10 +9,25 @@ This project uses: - **SQLAlchemy 2.0** with async support (`asyncpg` driver) - **Alembic** for schema migrations -- **Supabase Auth** as identity source -- **PostgreSQL** as primary database +- **Supabase Cloud** for Auth, Database, and Storage +- **PostgreSQL** as primary database (via Supabase connection pooler) - **Soft delete** pattern with `deleted_at` column +### Cloud Supabase Connection + +The project uses **Supabase Cloud** with connection pooling: + +```bash +# .env configuration +ERYAO_DATABASE__HOST=aws-1-us-east-2.pooler.supabase.com +ERYAO_DATABASE__PORT=5432 # Session pooler (IPv4 compatible) +ERYAO_DATABASE__NAME=postgres +ERYAO_DATABASE__USER=postgres. +ERYAO_DATABASE__PASSWORD= +``` + +**Note:** Direct database connection (port 5432 on `db..supabase.co`) requires IPv6 and is not suitable for most development environments. Use the connection pooler instead. + --- ## Query Patterns @@ -133,6 +148,8 @@ def downgrade() -> None: ./infra/scripts/dev-migrate.sh bootstrap ``` +**Note:** Cloud Supabase migrations may be slower than local due to network latency. Use appropriate timeouts for migration scripts. + **Alembic is the ONLY source of truth for schema changes.** --- diff --git a/.trellis/workflow.md b/.trellis/workflow.md index d1fe61e..fd01e35 100644 --- a/.trellis/workflow.md +++ b/.trellis/workflow.md @@ -101,6 +101,34 @@ cat .trellis/spec/backend/logging-guidelines.md # For logging 4. **Record Promptly** - Update tracking files immediately after completion 5. **Document Limits** - [!] **Max 2000 lines per journal document** +### Development Environment + +**Cloud Supabase Setup:** + +1. Configure `.env` with Supabase Cloud credentials: + ```bash + ERYAO_SUPABASE__PUBLIC_URL=https://.supabase.co + ERYAO_DATABASE__HOST=aws-1-us-east-2.pooler.supabase.com + ERYAO_DATABASE__PORT=5432 # Session pooler + ``` + +2. Start Redis (required for backend): + ```bash + cd infra/docker && docker compose up -d redis + ``` + +3. Run database migrations: + ```bash + ./infra/scripts/dev-migrate.sh bootstrap + ``` + +4. Start backend server: + ```bash + ./infra/scripts/app.sh start + ``` + +**Note:** Local Supabase is no longer used. All development uses Supabase Cloud. + ### File System ```