migration_4.py 432 B

123456789101112131415161718
  1. # Migration to add API column to token usage table
  2. from datetime import datetime
  3. def migration(conn):
  4. with conn.cursor() as cursor:
  5. cursor.execute(
  6. """
  7. ALTER TABLE token_usage ADD COLUMN api TEXT DEFAULT 'openai'
  8. """
  9. )
  10. cursor.execute(
  11. "INSERT INTO migrations (id, timestamp) VALUES (4, ?)",
  12. (datetime.now(),)
  13. )
  14. conn.commit()