All conn.cursor() calls replaced with get_cursor(conn) to enable
dict-like row access (prof['pin_hash'] instead of prof[column_index]).
This fixes KeyError when accessing PostgreSQL query results.
Fixes: 'tuple' object has no attribute '__getitem__' with string keys
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PostgreSQL DATE type doesn't accept empty strings ('').
Convert empty/whitespace date values to NULL during migration.
Fixes: invalid input syntax for type date: ""
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
SQLite schema (v9a) has meas_id in photos table, but PostgreSQL
schema (v9b) was missing it. This caused migration to fail.
Added meas_id as nullable UUID column for backward compatibility.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Bug: db_init.py was importing migrate_to_postgres but not calling main().
Result: Migration appeared successful but no data was migrated (0 users).
Fix: Import and call migrate_to_postgres.main()
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prepares production for SQLite → PostgreSQL migration:
- Add postgres service (mitai-db, port 5432)
- Add DB environment variables to backend
- Backend depends on postgres health check
- Uses startup.sh for automatic migration
Migration strategy:
1. SQLite data in /app/data/bodytrack.db is preserved (volume mounted)
2. On first start with empty PostgreSQL: automatic migration
3. Migration is safe: checks if profiles table is empty before migrating
4. After migration: all new data goes to PostgreSQL
IMPORTANT: Set DB_PASSWORD in .env before deploying!
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The data volume was missing in dev environment, preventing automatic
SQLite → PostgreSQL migration. The SQLite database (bodytrack.db) was
not accessible to the container, so migration was skipped.
This fixes the "No SQLite database found" message when data exists.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Frontend was sending {email, pin} but backend expects {email, password}.
This caused 422 Unprocessable Entity errors.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PostgreSQL does not support IF NOT EXISTS for CREATE TRIGGER.
Use DROP TRIGGER IF EXISTS before CREATE TRIGGER instead.
Fixes: Backend crash loop due to schema.sql syntax error on line 231
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove postgresql-client installation (causes 150s+ hangs due to network)
- Add db_init.py: Pure Python PostgreSQL checks using psycopg2-binary
- Simplify startup.sh: Call Python script instead of psql commands
- Build should now complete in <30s instead of hanging
This fixes the deployment timeout issue by avoiding APT network problems entirely.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Force IPv4 (IPv6 shows 33% packet loss)
- Increase retries to 5
- Add 10s timeouts to fail fast and retry
- Previous fix improved from 1630s to 78s but still hangs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Switch from deb.debian.org to ftp.de.debian.org (33% packet loss observed)
- Add APT retry logic (3 attempts) for flaky connections
- Fixes deployment timeout on backend build (postgresql-client install)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Added detailed documentation for:
- Color system (CSS variables)
- CSS class conventions
- Spacing & sizing standards
- Component patterns (loading, error, empty states)
- Jinkendo logo system
- Available custom commands
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>