diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 4ef3d2771..639ea789f 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -35,6 +35,10 @@ jobs: done echo "Service is up!" + - name: Delete Docker build cache + run: | + docker builder prune --all --force + - name: Preload Ollama model run: | docker exec ollama ollama pull qwen:0.5b-chat-v1.5-q2_K diff --git a/backend/apps/webui/internal/db.py b/backend/apps/webui/internal/db.py index aed110254..61025489f 100644 --- a/backend/apps/webui/internal/db.py +++ b/backend/apps/webui/internal/db.py @@ -81,12 +81,6 @@ handle_peewee_migration() SQLALCHEMY_DATABASE_URL = DATABASE_URL -# Replace the postgres:// with postgresql:// -if "postgres://" in SQLALCHEMY_DATABASE_URL: - SQLALCHEMY_DATABASE_URL = SQLALCHEMY_DATABASE_URL.replace( - "postgres://", "postgresql://" - ) - if "sqlite" in SQLALCHEMY_DATABASE_URL: engine = create_engine( SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False} diff --git a/backend/apps/webui/models/auths.py b/backend/apps/webui/models/auths.py index 9f6bd59e8..a17d92ff1 100644 --- a/backend/apps/webui/models/auths.py +++ b/backend/apps/webui/models/auths.py @@ -169,10 +169,10 @@ class AuthsTable: def update_user_password_by_id(self, id: str, new_password: str) -> bool: try: with get_db() as db: - result = ( db.query(Auth).filter_by(id=id).update({"password": new_password}) ) + db.commit() return True if result == 1 else False except: return False @@ -180,8 +180,8 @@ class AuthsTable: def update_email_by_id(self, id: str, email: str) -> bool: try: with get_db() as db: - result = db.query(Auth).filter_by(id=id).update({"email": email}) + db.commit() return True if result == 1 else False except: return False diff --git a/backend/apps/webui/models/chats.py b/backend/apps/webui/models/chats.py index ae63999a2..207bfab69 100644 --- a/backend/apps/webui/models/chats.py +++ b/backend/apps/webui/models/chats.py @@ -141,13 +141,14 @@ class ChatTable: db.add(shared_result) db.commit() db.refresh(shared_result) + # Update the original chat with the share_id result = ( db.query(Chat) .filter_by(id=chat_id) .update({"share_id": shared_chat.id}) ) - + db.commit() return shared_chat if (shared_result and result) else None def update_shared_chat_by_chat_id(self, chat_id: str) -> Optional[ChatModel]: @@ -206,8 +207,8 @@ class ChatTable: def archive_all_chats_by_user_id(self, user_id: str) -> bool: try: with get_db() as db: - db.query(Chat).filter_by(user_id=user_id).update({"archived": True}) + db.commit() return True except: return False diff --git a/backend/apps/webui/models/documents.py b/backend/apps/webui/models/documents.py index 16145c4ac..ac8655da9 100644 --- a/backend/apps/webui/models/documents.py +++ b/backend/apps/webui/models/documents.py @@ -158,6 +158,7 @@ class DocumentsTable: with get_db() as db: db.query(Document).filter_by(name=name).delete() + db.commit() return True except: return False diff --git a/backend/apps/webui/models/users.py b/backend/apps/webui/models/users.py index 8e3b57bba..2f30cda02 100644 --- a/backend/apps/webui/models/users.py +++ b/backend/apps/webui/models/users.py @@ -212,6 +212,7 @@ class UsersTable: try: with get_db() as db: db.query(User).filter_by(id=id).update({"oauth_sub": oauth_sub}) + db.commit() user = db.query(User).filter_by(id=id).first() return UserModel.model_validate(user) diff --git a/backend/config.py b/backend/config.py index fcf44b3ef..4db04ea65 100644 --- a/backend/config.py +++ b/backend/config.py @@ -1331,3 +1331,7 @@ AUDIO_TTS_VOICE = PersistentConfig( #################################### DATABASE_URL = os.environ.get("DATABASE_URL", f"sqlite:///{DATA_DIR}/webui.db") + +# Replace the postgres:// with postgresql:// +if "postgres://" in DATABASE_URL: + DATABASE_URL = DATABASE_URL.replace("postgres://", "postgresql://") diff --git a/backend/main.py b/backend/main.py index 2da19c5c7..c37124f1e 100644 --- a/backend/main.py +++ b/backend/main.py @@ -173,13 +173,11 @@ https://github.com/open-webui/open-webui def run_migrations(): - env = os.environ.copy() - env["DATABASE_URL"] = DATABASE_URL - migration_task = subprocess.run( - ["alembic", f"-c{BACKEND_DIR}/alembic.ini", "upgrade", "head"], env=env - ) - if migration_task.returncode > 0: - raise ValueError("Error running migrations") + from alembic.config import Config + from alembic import command + + alembic_cfg = Config("alembic.ini") + command.upgrade(alembic_cfg, "head") @asynccontextmanager diff --git a/backend/migrations/env.py b/backend/migrations/env.py index 836893bbe..efd37445f 100644 --- a/backend/migrations/env.py +++ b/backend/migrations/env.py @@ -18,6 +18,8 @@ from apps.webui.models.users import User from apps.webui.models.files import File from apps.webui.models.functions import Function +from config import DATABASE_URL + # this is the Alembic Config object, which provides # access to the values within the .ini file in use. config = context.config @@ -38,9 +40,16 @@ target_metadata = Auth.metadata # my_important_option = config.get_main_option("my_important_option") # ... etc. -database_url = os.getenv("DATABASE_URL", None) -if database_url: - config.set_main_option("sqlalchemy.url", database_url) +DB_URL = DATABASE_URL +# Replace the postgres:// with postgresql:// +if "postgres://" in DB_URL: + DB_URL = DB_URL.replace("postgres://", "postgresql://") + +if DB_URL: + config.set_main_option("sqlalchemy.url", DB_URL) + + +print("DB_URL", DB_URL) def run_migrations_offline() -> None: diff --git a/backend/requirements.txt b/backend/requirements.txt index 6d3371628..7317a6706 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -13,7 +13,7 @@ passlib[bcrypt]==1.7.4 requests==2.32.3 aiohttp==3.9.5 sqlalchemy==2.0.30 -alembic==1.13.1 +alembic==1.13.2 peewee==3.17.6 peewee-migrate==1.12.2 psycopg2-binary==2.9.9 @@ -51,7 +51,7 @@ pyxlsb==1.0.10 xlrd==2.0.1 validators==0.28.1 -opencv-python-headless==4.9.0.80 +opencv-python-headless==4.10.0.84 rapidocr-onnxruntime==1.3.22 fpdf2==2.7.9 @@ -73,5 +73,5 @@ duckduckgo-search~=6.1.7 ## Tests docker~=7.1.0 -pytest~=8.2.1 +pytest~=8.2.2 pytest-docker~=3.1.1 diff --git a/src/lib/i18n/locales/vi-VN/translation.json b/src/lib/i18n/locales/vi-VN/translation.json index b3def6335..aaea87bdc 100644 --- a/src/lib/i18n/locales/vi-VN/translation.json +++ b/src/lib/i18n/locales/vi-VN/translation.json @@ -182,7 +182,7 @@ "Discover, download, and explore custom functions": "Tìm kiếm, tải về và khám phá thêm các function tùy chỉnh", "Discover, download, and explore custom prompts": "Tìm kiếm, tải về và khám phá thêm các prompt tùy chỉnh", "Discover, download, and explore custom tools": "Tìm kiếm, tải về và khám phá thêm các tool tùy chỉnh", - "Discover, download, and explore model preseKhts": "Tìm kiếm, tải về và khám phá thêm các thiết lập mô hình sẵn", + "Discover, download, and explore model presets": "", "Dismissible": "Có thể loại bỏ", "Display Emoji in Call": "Hiển thị Emoji trong cuộc gọi", "Display the username instead of You in the Chat": "Hiển thị tên người sử dụng thay vì 'Bạn' trong nội dung chat",