From 9263b7568eaa83f43e4a118c98490c4f7aaba570 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 14 May 2026 14:12:42 +0900 Subject: [PATCH] refac Co-Authored-By: Classic298 <27028174+Classic298@users.noreply.github.com> --- .../4ace53fd72c8_update_folder_table_datetime.py | 12 ++++++++---- .../versions/56359461a091_add_calendar_tables.py | 3 +++ .../versions/d4e5f6a7b8c9_add_automation_tables.py | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/backend/open_webui/migrations/versions/4ace53fd72c8_update_folder_table_datetime.py b/backend/open_webui/migrations/versions/4ace53fd72c8_update_folder_table_datetime.py index ac0d45016d..e1e3b32635 100644 --- a/backend/open_webui/migrations/versions/4ace53fd72c8_update_folder_table_datetime.py +++ b/backend/open_webui/migrations/versions/4ace53fd72c8_update_folder_table_datetime.py @@ -60,20 +60,24 @@ def upgrade(): def downgrade(): - # Downgrade: Convert columns back to DateTime and restore defaults + # Convert columns back to DateTime and restore defaults. Mirrors the + # upgrade's postgresql_using cast — without it, Postgres can't + # auto-cast BigInteger → timestamp and aborts with DatatypeMismatch. with op.batch_alter_table('folder', schema=None) as batch_op: batch_op.alter_column( 'created_at', type_=sa.DateTime(), existing_type=sa.BigInteger(), existing_nullable=False, - server_default=sa.func.now(), # Restoring server default on downgrade + server_default=sa.func.now(), + postgresql_using='to_timestamp(created_at)::timestamp without time zone', ) batch_op.alter_column( 'updated_at', type_=sa.DateTime(), existing_type=sa.BigInteger(), existing_nullable=False, - server_default=sa.func.now(), # Restoring server default on downgrade - onupdate=sa.func.now(), # Restoring onupdate behavior if it was there + server_default=sa.func.now(), + onupdate=sa.func.now(), + postgresql_using='to_timestamp(updated_at)::timestamp without time zone', ) diff --git a/backend/open_webui/migrations/versions/56359461a091_add_calendar_tables.py b/backend/open_webui/migrations/versions/56359461a091_add_calendar_tables.py index 7a61e3a0af..571390a6fa 100644 --- a/backend/open_webui/migrations/versions/56359461a091_add_calendar_tables.py +++ b/backend/open_webui/migrations/versions/56359461a091_add_calendar_tables.py @@ -44,6 +44,7 @@ def upgrade() -> None: sa.PrimaryKeyConstraint('id'), ) + inspector.clear_cache() if 'calendar' in inspector.get_table_names(): if not _index_exists(inspector, 'ix_calendar_user', 'calendar'): op.create_index('ix_calendar_user', 'calendar', ['user_id'], unique=False) @@ -70,6 +71,7 @@ def upgrade() -> None: sa.PrimaryKeyConstraint('id'), ) + inspector.clear_cache() if 'calendar_event' in inspector.get_table_names(): if not _index_exists(inspector, 'ix_calendar_event_calendar', 'calendar_event'): op.create_index('ix_calendar_event_calendar', 'calendar_event', ['calendar_id', 'start_at'], unique=False) @@ -90,6 +92,7 @@ def upgrade() -> None: sa.UniqueConstraint('event_id', 'user_id', name='uq_event_attendee'), ) + inspector.clear_cache() if 'calendar_event_attendee' in inspector.get_table_names(): if not _index_exists(inspector, 'ix_calendar_event_attendee_user', 'calendar_event_attendee'): op.create_index('ix_calendar_event_attendee_user', 'calendar_event_attendee', ['user_id', 'status'], unique=False) diff --git a/backend/open_webui/migrations/versions/d4e5f6a7b8c9_add_automation_tables.py b/backend/open_webui/migrations/versions/d4e5f6a7b8c9_add_automation_tables.py index 30fc2bb871..1df1cf7092 100644 --- a/backend/open_webui/migrations/versions/d4e5f6a7b8c9_add_automation_tables.py +++ b/backend/open_webui/migrations/versions/d4e5f6a7b8c9_add_automation_tables.py @@ -42,7 +42,7 @@ def upgrade(): sa.Column('updated_at', sa.BigInteger(), nullable=False), ) - # Re-check tables in case we just created it + inspector.clear_cache() if 'automation' in inspector.get_table_names(): if not _index_exists(inspector, 'ix_automation_next_run', 'automation'): op.create_index('ix_automation_next_run', 'automation', ['next_run_at']) @@ -58,6 +58,7 @@ def upgrade(): sa.Column('created_at', sa.BigInteger(), nullable=False), ) + inspector.clear_cache() if 'automation_run' in inspector.get_table_names(): if not _index_exists(inspector, 'ix_automation_run_automation_id', 'automation_run'): op.create_index(