open-webui/backend/open_webui/migrations/versions
Classic298 b4f340806a
fix: migration streaming/batching (#21542)
* fix: normalize usage tokens + migration streaming/batching

- Migration: replace .fetchall() with yield_per streaming, replace per-message INSERT+SAVEPOINT with batched inserts (5k/batch) with fallback to row-by-row on error, add progress logging

- Write path: call normalize_usage() in upsert_message() before saving to ensure input_tokens/output_tokens always present

- Read path: analytics queries now COALESCE across input_tokens/prompt_tokens and output_tokens/completion_tokens so historical data with OpenAI-format keys is visible

* fix: restore defensive timestamp conversion in migration

Re-add try/except around int(float(timestamp)) that was accidentally dropped. Without this, a non-numeric timestamp string would cause a TypeError on the subsequent comparison, breaking the entire upgrade.

* revert: remove changes to chat_messages.py
2026-03-07 19:08:11 -05:00
..
1af9b942657b_migrate_tags.py fix: duplicate tags 2024-10-14 23:04:10 -07:00
2f1211949ecc_update_message_and_channel_member_table.py chore: format 2026-02-11 16:24:11 -06:00
3ab32c4b8f59_update_tags.py fix: tag migration 2024-10-14 13:45:09 -07:00
3af16a1c9fb6_update_user_table.py refac: account details 2025-08-21 02:39:25 +04:00
3e0e00844bb0_add_knowledge_file_table.py refac 2025-12-02 11:00:34 -05:00
4ace53fd72c8_update_folder_table_datetime.py fix: folder migration 2024-10-23 14:58:28 -07:00
6a39f3d8e55c_add_knowledge_table.py chore: format 2026-02-11 16:24:11 -06:00
7e5b5dc7342b_init.py wip 2024-12-10 00:54:13 -08:00
9f0c9cd09105_add_note_table.py feat: notes 2025-05-03 18:16:32 +04:00
37f288994c47_add_group_member_table.py chore: format 2026-02-11 16:24:11 -06:00
38d63c18f30f_add_oauth_session_table.py chore: format 2026-02-11 16:24:11 -06:00
57c599a3cb57_add_channel_table.py refac 2024-12-22 22:08:27 -07:00
81cc2ce44d79_update_channel_file_and_knowledge_table.py chore: format 2026-02-11 16:24:11 -06:00
90ef40d4714e_update_channel_and_channel_members_table.py chore: format 2026-02-11 16:24:11 -06:00
242a2047eae0_update_chat_table.py refac: migration 2024-10-26 19:01:01 -07:00
374d2f66af06_add_prompt_history_table.py chore: format 2026-02-11 16:24:11 -06:00
922e7a387820_add_group_table.py refac: migration 2024-11-16 14:56:00 -08:00
3781e22d8b01_update_message_table.py feat: reactions 2024-12-30 23:06:34 -08:00
6283dc0e4d8d_add_channel_file_table.py chore: format 2026-02-11 16:24:11 -06:00
7826ab40b532_update_file_table.py enh: channel file upload 2024-12-23 14:43:58 -07:00
8452d01d26d7_add_chat_message_table.py fix: migration streaming/batching (#21542) 2026-03-07 19:08:11 -05:00
018012973d35_add_indexes.py refac/enh: add performance indexes 2025-08-19 03:24:10 +04:00
a1b2c3d4e5f6_add_skill_table.py refac 2026-02-11 14:26:56 -06:00
a5c220713937_add_reply_to_id_column_to_message.py enh: reply to message 2025-09-27 04:05:12 -05:00
af906e964978_add_feedback_table.py refac: feedback 2024-10-22 22:55:34 -07:00
b2c3d4e5f6a7_add_scim_column_to_user_table.py refac: scim 2026-02-13 14:27:11 -06:00
b10670c03dd5_update_user_table.py chore: format 2026-02-11 16:24:11 -06:00
c0fbf31ca0db_update_file_table.py refac 2024-10-02 21:14:58 -07:00
c29facfe716b_update_file_table_path.py chore: format 2026-02-11 16:24:11 -06:00
c69f45358db4_add_folder_table.py enh: save isExpanded state 2024-10-16 22:58:28 -07:00
c440947495f3_add_chat_file_table.py chore: format 2026-02-11 16:24:11 -06:00
ca81bd47c050_add_config_table.py refac: mv backend files to /open_webui dir 2024-09-04 16:54:48 +02:00
d31026856c01_update_folder_table_data.py feat: migrate folder table 2025-07-13 00:51:58 +04:00
f1e2d3c4b5a6_add_access_grant_table.py chore: format 2026-02-11 16:24:11 -06:00