Spaces:
Running on Zero
Running on Zero
Commit History
28 days ago
-
fix: await the timezone lookup, and copy Postgres data across environments
The timezone fix in 2cdaf35 was broken and the regression test could not catch it. `user_today()` called the async `_tz_for()` without awaiting it, so pytz.timezone() received a coroutine, raised, and the code silently fell back to the machine timezone -- exactly the bug it was supposed to fix. The test passed because it asserted the fallback result. `user_today()` is now async and every caller awaits it, and the test sets two different timezones for the same frozen instant so a fallback can no longer satisfy it. Also add scripts/copy_postgres.py for the actual data migration. The bot's history lived in SQLite, was migrated to a local Postgres, and Supabase only ever received the schema -- so the production bot started from an empty database. The copy is additive (ON CONFLICT DO NOTHING never updates or deletes), offsets primary keys because local ids overlapped Supabase's (1..26 vs 21..22, 1..160 vs 1..14) and ON CONFLICT would otherwise silently drop rows, and never overwrites a use…7d3a67d
29 days ago
-
feat: switch to Postgres, add intent router and a warmer persona
Database - Replace SQLite (aiosqlite) with PostgreSQL via asyncpg. All state lived on the container's ephemeral filesystem, which is why every redeploy wiped it. - Add versioned migrations (database/migrations/NNN_*.sql) recorded in schema_migrations with checksums. The old CREATE-IF-NOT-EXISTS approach could not evolve the schema, and the live DB had drifted (orphaned google_calendar_tokens table). - Drop write-only daily_nutrition cache; totals recompute from food_logs so edits stay consistent. - connection.py keeps the small subset of the aiosqlite API the services use (`await db.execute`, `async with db.execute as cursor`, fetchone/fetchall) and translates ? placeholders to $n, so call sites were left untouched. - Store activity_dt as TIMESTAMPTZ and drop the string-comparison reminder query; reminders are now correct for WIB/WITA/WIT users. - Add scripts/migrate_sqlite_to_postgres.py to move the existing 4 users, 26 food logs and 160 conversations across with ids…1fcc069