Skip to content

Commit

Permalink
update date_created field default by local time
Browse files Browse the repository at this point in the history
  • Loading branch information
cin-cris committed Nov 11, 2024
1 parent c4a810e commit a5993f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 5 additions & 4 deletions libs/ktem/ktem/index/file/index.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import uuid
from datetime import datetime
from typing import Any, Optional, Type

from ktem.components import filestorage_path, get_docstore, get_vectorstore
Expand All @@ -7,9 +8,9 @@
from sqlalchemy import JSON, Column, DateTime, Integer, String, UniqueConstraint
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.mutable import MutableDict
from sqlalchemy.sql import func
from theflow.settings import settings as flowsettings
from theflow.utils.modules import import_dotted_string
from tzlocal import get_localzone

from kotaemon.storages import BaseDocumentStore, BaseVectorStore

Expand Down Expand Up @@ -73,7 +74,7 @@ def _setup_resources(self):
"path": Column(String),
"size": Column(Integer, default=0),
"date_created": Column(
DateTime(timezone=True), server_default=func.now()
DateTime(timezone=True), default=datetime.now(get_localzone())
),
"user": Column(Integer, default=1),
"note": Column(
Expand All @@ -98,7 +99,7 @@ def _setup_resources(self):
"path": Column(String),
"size": Column(Integer, default=0),
"date_created": Column(
DateTime(timezone=True), server_default=func.now()
DateTime(timezone=True), default=datetime.now(get_localzone())
),
"user": Column(Integer, default=1),
"note": Column(
Expand Down Expand Up @@ -126,7 +127,7 @@ def _setup_resources(self):
"__tablename__": f"index__{self.id}__group",
"id": Column(Integer, primary_key=True, autoincrement=True),
"date_created": Column(
DateTime(timezone=True), server_default=func.now()
DateTime(timezone=True), default=datetime.now(get_localzone())
),
"name": Column(String, unique=True),
"user": Column(Integer, default=1),
Expand Down
7 changes: 4 additions & 3 deletions scripts/migrate/migrate_chroma_db.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import uuid
from datetime import datetime

import chromadb
from ktem.index.models import Index
Expand All @@ -15,7 +16,7 @@
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.mutable import MutableDict
from sqlalchemy.orm import Session
from sqlalchemy.sql import func
from tzlocal import get_localzone


def _init_resource(private: bool = True, id: int = 1):
Expand All @@ -41,7 +42,7 @@ def _init_resource(private: bool = True, id: int = 1):
"path": Column(String),
"size": Column(Integer, default=0),
"date_created": Column(
DateTime(timezone=True), server_default=func.now()
DateTime(timezone=True), default=datetime.now(get_localzone())
),
"user": Column(Integer, default=1),
"note": Column(
Expand All @@ -66,7 +67,7 @@ def _init_resource(private: bool = True, id: int = 1):
"path": Column(String),
"size": Column(Integer, default=0),
"date_created": Column(
DateTime(timezone=True), server_default=func.now()
DateTime(timezone=True), default=datetime.now(get_localzone())
),
"user": Column(Integer, default=1),
"note": Column(
Expand Down

0 comments on commit a5993f3

Please sign in to comment.