mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
refac: switch to meta and params, remove source
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import json
|
||||
|
||||
from peewee import *
|
||||
from peewee_migrate import Router
|
||||
from playhouse.db_url import connect
|
||||
@@ -8,6 +10,16 @@ import logging
|
||||
log = logging.getLogger(__name__)
|
||||
log.setLevel(SRC_LOG_LEVELS["DB"])
|
||||
|
||||
|
||||
class JSONField(TextField):
|
||||
def db_value(self, value):
|
||||
return json.dumps(value)
|
||||
|
||||
def python_value(self, value):
|
||||
if value is not None:
|
||||
return json.loads(value)
|
||||
|
||||
|
||||
# Check if the file exists
|
||||
if os.path.exists(f"{DATA_DIR}/ollama.db"):
|
||||
# Rename the file
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Peewee migrations -- 008_add_models.py.
|
||||
"""Peewee migrations -- 009_add_models.py.
|
||||
|
||||
Some examples (model - class or model name)::
|
||||
|
||||
@@ -39,20 +39,15 @@ def migrate(migrator: Migrator, database: pw.Database, *, fake=False):
|
||||
|
||||
@migrator.create_model
|
||||
class Model(pw.Model):
|
||||
id = pw.TextField()
|
||||
source = pw.TextField()
|
||||
base_model = pw.TextField(null=True)
|
||||
id = pw.TextField(unique=True)
|
||||
meta = pw.TextField()
|
||||
base_model_id = pw.TextField(null=True)
|
||||
name = pw.TextField()
|
||||
params = pw.TextField()
|
||||
|
||||
class Meta:
|
||||
table_name = "model"
|
||||
|
||||
indexes = (
|
||||
# Create a unique index on the id, source columns
|
||||
(("id", "source"), True),
|
||||
)
|
||||
|
||||
|
||||
def rollback(migrator: Migrator, database: pw.Database, *, fake=False):
|
||||
"""Write your rollback migrations here."""
|
||||
Reference in New Issue
Block a user