Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
a9b14879
Commit
a9b14879
authored
Jun 24, 2024
by
Jonathan Rohde
Browse files
feat(sqlalchemy): fix wrong column types
parent
da403f3e
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
214 additions
and
202 deletions
+214
-202
backend/apps/webui/models/auths.py
backend/apps/webui/models/auths.py
+2
-2
backend/apps/webui/models/chats.py
backend/apps/webui/models/chats.py
+4
-4
backend/apps/webui/models/documents.py
backend/apps/webui/models/documents.py
+4
-4
backend/apps/webui/models/files.py
backend/apps/webui/models/files.py
+2
-2
backend/apps/webui/models/memories.py
backend/apps/webui/models/memories.py
+2
-2
backend/apps/webui/models/models.py
backend/apps/webui/models/models.py
+5
-5
backend/apps/webui/models/prompts.py
backend/apps/webui/models/prompts.py
+3
-3
backend/apps/webui/models/tags.py
backend/apps/webui/models/tags.py
+2
-2
backend/apps/webui/models/tools.py
backend/apps/webui/models/tools.py
+3
-3
backend/apps/webui/models/users.py
backend/apps/webui/models/users.py
+1
-1
backend/migrations/versions/7e5b5dc7342b_init.py
backend/migrations/versions/7e5b5dc7342b_init.py
+186
-0
backend/migrations/versions/ba76b0bae648_init.py
backend/migrations/versions/ba76b0bae648_init.py
+0
-174
No files found.
backend/apps/webui/models/auths.py
View file @
a9b14879
...
@@ -2,7 +2,7 @@ from pydantic import BaseModel
...
@@ -2,7 +2,7 @@ from pydantic import BaseModel
from
typing
import
Optional
from
typing
import
Optional
import
uuid
import
uuid
import
logging
import
logging
from
sqlalchemy
import
String
,
Column
,
Boolean
from
sqlalchemy
import
String
,
Column
,
Boolean
,
Text
from
apps.webui.models.users
import
UserModel
,
Users
from
apps.webui.models.users
import
UserModel
,
Users
from
utils.utils
import
verify_password
from
utils.utils
import
verify_password
...
@@ -24,7 +24,7 @@ class Auth(Base):
...
@@ -24,7 +24,7 @@ class Auth(Base):
id
=
Column
(
String
,
primary_key
=
True
)
id
=
Column
(
String
,
primary_key
=
True
)
email
=
Column
(
String
)
email
=
Column
(
String
)
password
=
Column
(
String
)
password
=
Column
(
Text
)
active
=
Column
(
Boolean
)
active
=
Column
(
Boolean
)
...
...
backend/apps/webui/models/chats.py
View file @
a9b14879
...
@@ -5,7 +5,7 @@ import json
...
@@ -5,7 +5,7 @@ import json
import
uuid
import
uuid
import
time
import
time
from
sqlalchemy
import
Column
,
String
,
BigInteger
,
Boolean
from
sqlalchemy
import
Column
,
String
,
BigInteger
,
Boolean
,
Text
from
apps.webui.internal.db
import
Base
,
Session
from
apps.webui.internal.db
import
Base
,
Session
...
@@ -20,13 +20,13 @@ class Chat(Base):
...
@@ -20,13 +20,13 @@ class Chat(Base):
id
=
Column
(
String
,
primary_key
=
True
)
id
=
Column
(
String
,
primary_key
=
True
)
user_id
=
Column
(
String
)
user_id
=
Column
(
String
)
title
=
Column
(
String
)
title
=
Column
(
Text
)
chat
=
Column
(
String
)
# Save Chat JSON as Text
chat
=
Column
(
Text
)
# Save Chat JSON as Text
created_at
=
Column
(
BigInteger
)
created_at
=
Column
(
BigInteger
)
updated_at
=
Column
(
BigInteger
)
updated_at
=
Column
(
BigInteger
)
share_id
=
Column
(
String
,
unique
=
True
,
nullable
=
True
)
share_id
=
Column
(
Text
,
unique
=
True
,
nullable
=
True
)
archived
=
Column
(
Boolean
,
default
=
False
)
archived
=
Column
(
Boolean
,
default
=
False
)
...
...
backend/apps/webui/models/documents.py
View file @
a9b14879
...
@@ -3,7 +3,7 @@ from typing import List, Optional
...
@@ -3,7 +3,7 @@ from typing import List, Optional
import
time
import
time
import
logging
import
logging
from
sqlalchemy
import
String
,
Column
,
BigInteger
from
sqlalchemy
import
String
,
Column
,
BigInteger
,
Text
from
apps.webui.internal.db
import
Base
,
Session
from
apps.webui.internal.db
import
Base
,
Session
...
@@ -24,9 +24,9 @@ class Document(Base):
...
@@ -24,9 +24,9 @@ class Document(Base):
collection_name
=
Column
(
String
,
primary_key
=
True
)
collection_name
=
Column
(
String
,
primary_key
=
True
)
name
=
Column
(
String
,
unique
=
True
)
name
=
Column
(
String
,
unique
=
True
)
title
=
Column
(
String
)
title
=
Column
(
Text
)
filename
=
Column
(
String
)
filename
=
Column
(
Text
)
content
=
Column
(
String
,
nullable
=
True
)
content
=
Column
(
Text
,
nullable
=
True
)
user_id
=
Column
(
String
)
user_id
=
Column
(
String
)
timestamp
=
Column
(
BigInteger
)
timestamp
=
Column
(
BigInteger
)
...
...
backend/apps/webui/models/files.py
View file @
a9b14879
...
@@ -3,7 +3,7 @@ from typing import List, Union, Optional
...
@@ -3,7 +3,7 @@ from typing import List, Union, Optional
import
time
import
time
import
logging
import
logging
from
sqlalchemy
import
Column
,
String
,
BigInteger
from
sqlalchemy
import
Column
,
String
,
BigInteger
,
Text
from
apps.webui.internal.db
import
JSONField
,
Base
,
Session
from
apps.webui.internal.db
import
JSONField
,
Base
,
Session
...
@@ -24,7 +24,7 @@ class File(Base):
...
@@ -24,7 +24,7 @@ class File(Base):
id
=
Column
(
String
,
primary_key
=
True
)
id
=
Column
(
String
,
primary_key
=
True
)
user_id
=
Column
(
String
)
user_id
=
Column
(
String
)
filename
=
Column
(
String
)
filename
=
Column
(
Text
)
meta
=
Column
(
JSONField
)
meta
=
Column
(
JSONField
)
created_at
=
Column
(
BigInteger
)
created_at
=
Column
(
BigInteger
)
...
...
backend/apps/webui/models/memories.py
View file @
a9b14879
from
pydantic
import
BaseModel
,
ConfigDict
from
pydantic
import
BaseModel
,
ConfigDict
from
typing
import
List
,
Union
,
Optional
from
typing
import
List
,
Union
,
Optional
from
sqlalchemy
import
Column
,
String
,
BigInteger
from
sqlalchemy
import
Column
,
String
,
BigInteger
,
Text
from
apps.webui.internal.db
import
Base
,
Session
from
apps.webui.internal.db
import
Base
,
Session
...
@@ -18,7 +18,7 @@ class Memory(Base):
...
@@ -18,7 +18,7 @@ class Memory(Base):
id
=
Column
(
String
,
primary_key
=
True
)
id
=
Column
(
String
,
primary_key
=
True
)
user_id
=
Column
(
String
)
user_id
=
Column
(
String
)
content
=
Column
(
String
)
content
=
Column
(
Text
)
updated_at
=
Column
(
BigInteger
)
updated_at
=
Column
(
BigInteger
)
created_at
=
Column
(
BigInteger
)
created_at
=
Column
(
BigInteger
)
...
...
backend/apps/webui/models/models.py
View file @
a9b14879
...
@@ -3,7 +3,7 @@ import logging
...
@@ -3,7 +3,7 @@ import logging
from
typing
import
Optional
from
typing
import
Optional
from
pydantic
import
BaseModel
,
ConfigDict
from
pydantic
import
BaseModel
,
ConfigDict
from
sqlalchemy
import
String
,
Column
,
BigInteger
from
sqlalchemy
import
String
,
Column
,
BigInteger
,
Text
from
apps.webui.internal.db
import
Base
,
JSONField
,
Session
from
apps.webui.internal.db
import
Base
,
JSONField
,
Session
...
@@ -46,18 +46,18 @@ class ModelMeta(BaseModel):
...
@@ -46,18 +46,18 @@ class ModelMeta(BaseModel):
class
Model
(
Base
):
class
Model
(
Base
):
__tablename__
=
"model"
__tablename__
=
"model"
id
=
Column
(
String
,
primary_key
=
True
)
id
=
Column
(
Text
,
primary_key
=
True
)
"""
"""
The model's id as used in the API. If set to an existing model, it will override the model.
The model's id as used in the API. If set to an existing model, it will override the model.
"""
"""
user_id
=
Column
(
String
)
user_id
=
Column
(
Text
)
base_model_id
=
Column
(
String
,
nullable
=
True
)
base_model_id
=
Column
(
Text
,
nullable
=
True
)
"""
"""
An optional pointer to the actual model that should be used when proxying requests.
An optional pointer to the actual model that should be used when proxying requests.
"""
"""
name
=
Column
(
String
)
name
=
Column
(
Text
)
"""
"""
The human-readable display name of the model.
The human-readable display name of the model.
"""
"""
...
...
backend/apps/webui/models/prompts.py
View file @
a9b14879
...
@@ -2,7 +2,7 @@ from pydantic import BaseModel, ConfigDict
...
@@ -2,7 +2,7 @@ from pydantic import BaseModel, ConfigDict
from
typing
import
List
,
Optional
from
typing
import
List
,
Optional
import
time
import
time
from
sqlalchemy
import
String
,
Column
,
BigInteger
from
sqlalchemy
import
String
,
Column
,
BigInteger
,
Text
from
apps.webui.internal.db
import
Base
,
Session
from
apps.webui.internal.db
import
Base
,
Session
...
@@ -18,8 +18,8 @@ class Prompt(Base):
...
@@ -18,8 +18,8 @@ class Prompt(Base):
command
=
Column
(
String
,
primary_key
=
True
)
command
=
Column
(
String
,
primary_key
=
True
)
user_id
=
Column
(
String
)
user_id
=
Column
(
String
)
title
=
Column
(
String
)
title
=
Column
(
Text
)
content
=
Column
(
String
)
content
=
Column
(
Text
)
timestamp
=
Column
(
BigInteger
)
timestamp
=
Column
(
BigInteger
)
...
...
backend/apps/webui/models/tags.py
View file @
a9b14879
...
@@ -6,7 +6,7 @@ import uuid
...
@@ -6,7 +6,7 @@ import uuid
import
time
import
time
import
logging
import
logging
from
sqlalchemy
import
String
,
Column
,
BigInteger
from
sqlalchemy
import
String
,
Column
,
BigInteger
,
Text
from
apps.webui.internal.db
import
Base
,
Session
from
apps.webui.internal.db
import
Base
,
Session
...
@@ -26,7 +26,7 @@ class Tag(Base):
...
@@ -26,7 +26,7 @@ class Tag(Base):
id
=
Column
(
String
,
primary_key
=
True
)
id
=
Column
(
String
,
primary_key
=
True
)
name
=
Column
(
String
)
name
=
Column
(
String
)
user_id
=
Column
(
String
)
user_id
=
Column
(
String
)
data
=
Column
(
String
,
nullable
=
True
)
data
=
Column
(
Text
,
nullable
=
True
)
class
ChatIdTag
(
Base
):
class
ChatIdTag
(
Base
):
...
...
backend/apps/webui/models/tools.py
View file @
a9b14879
...
@@ -2,7 +2,7 @@ from pydantic import BaseModel, ConfigDict
...
@@ -2,7 +2,7 @@ from pydantic import BaseModel, ConfigDict
from
typing
import
List
,
Optional
from
typing
import
List
,
Optional
import
time
import
time
import
logging
import
logging
from
sqlalchemy
import
String
,
Column
,
BigInteger
from
sqlalchemy
import
String
,
Column
,
BigInteger
,
Text
from
apps.webui.internal.db
import
Base
,
JSONField
,
Session
from
apps.webui.internal.db
import
Base
,
JSONField
,
Session
from
apps.webui.models.users
import
Users
from
apps.webui.models.users
import
Users
...
@@ -26,8 +26,8 @@ class Tool(Base):
...
@@ -26,8 +26,8 @@ class Tool(Base):
id
=
Column
(
String
,
primary_key
=
True
)
id
=
Column
(
String
,
primary_key
=
True
)
user_id
=
Column
(
String
)
user_id
=
Column
(
String
)
name
=
Column
(
String
)
name
=
Column
(
Text
)
content
=
Column
(
String
)
content
=
Column
(
Text
)
specs
=
Column
(
JSONField
)
specs
=
Column
(
JSONField
)
meta
=
Column
(
JSONField
)
meta
=
Column
(
JSONField
)
valves
=
Column
(
JSONField
)
valves
=
Column
(
JSONField
)
...
...
backend/apps/webui/models/users.py
View file @
a9b14879
...
@@ -21,7 +21,7 @@ class User(Base):
...
@@ -21,7 +21,7 @@ class User(Base):
name
=
Column
(
String
)
name
=
Column
(
String
)
email
=
Column
(
String
)
email
=
Column
(
String
)
role
=
Column
(
String
)
role
=
Column
(
String
)
profile_image_url
=
Column
(
String
)
profile_image_url
=
Column
(
Text
)
last_active_at
=
Column
(
BigInteger
)
last_active_at
=
Column
(
BigInteger
)
updated_at
=
Column
(
BigInteger
)
updated_at
=
Column
(
BigInteger
)
...
...
backend/migrations/versions/7e5b5dc7342b_init.py
0 → 100644
View file @
a9b14879
"""init
Revision ID: 7e5b5dc7342b
Revises:
Create Date: 2024-06-24 13:15:33.808998
"""
from
typing
import
Sequence
,
Union
from
alembic
import
op
import
sqlalchemy
as
sa
import
apps.webui.internal.db
from
migrations.util
import
get_existing_tables
# revision identifiers, used by Alembic.
revision
:
str
=
'7e5b5dc7342b'
down_revision
:
Union
[
str
,
None
]
=
None
branch_labels
:
Union
[
str
,
Sequence
[
str
],
None
]
=
None
depends_on
:
Union
[
str
,
Sequence
[
str
],
None
]
=
None
def
upgrade
()
->
None
:
existing_tables
=
set
(
get_existing_tables
())
# ### commands auto generated by Alembic - please adjust! ###
if
"auth"
not
in
existing_tables
:
op
.
create_table
(
'auth'
,
sa
.
Column
(
'id'
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
'email'
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
'password'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
'active'
,
sa
.
Boolean
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
'id'
)
)
if
"chat"
not
in
existing_tables
:
op
.
create_table
(
'chat'
,
sa
.
Column
(
'id'
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
'user_id'
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
'title'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
'chat'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
'created_at'
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
Column
(
'updated_at'
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
Column
(
'share_id'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
'archived'
,
sa
.
Boolean
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
'id'
),
sa
.
UniqueConstraint
(
'share_id'
)
)
if
"chatidtag"
not
in
existing_tables
:
op
.
create_table
(
'chatidtag'
,
sa
.
Column
(
'id'
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
'tag_name'
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
'chat_id'
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
'user_id'
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
'timestamp'
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
'id'
)
)
if
"document"
not
in
existing_tables
:
op
.
create_table
(
'document'
,
sa
.
Column
(
'collection_name'
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
'name'
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
'title'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
'filename'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
'content'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
'user_id'
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
'timestamp'
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
'collection_name'
),
sa
.
UniqueConstraint
(
'name'
)
)
if
"file"
not
in
existing_tables
:
op
.
create_table
(
'file'
,
sa
.
Column
(
'id'
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
'user_id'
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
'filename'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
'meta'
,
apps
.
webui
.
internal
.
db
.
JSONField
(),
nullable
=
True
),
sa
.
Column
(
'created_at'
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
'id'
)
)
if
"function"
not
in
existing_tables
:
op
.
create_table
(
'function'
,
sa
.
Column
(
'id'
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
'user_id'
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
'name'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
'type'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
'content'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
'meta'
,
apps
.
webui
.
internal
.
db
.
JSONField
(),
nullable
=
True
),
sa
.
Column
(
'valves'
,
apps
.
webui
.
internal
.
db
.
JSONField
(),
nullable
=
True
),
sa
.
Column
(
'is_active'
,
sa
.
Boolean
(),
nullable
=
True
),
sa
.
Column
(
'updated_at'
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
Column
(
'created_at'
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
'id'
)
)
if
"memory"
not
in
existing_tables
:
op
.
create_table
(
'memory'
,
sa
.
Column
(
'id'
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
'user_id'
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
'content'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
'updated_at'
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
Column
(
'created_at'
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
'id'
)
)
if
"model"
not
in
existing_tables
:
op
.
create_table
(
'model'
,
sa
.
Column
(
'id'
,
sa
.
Text
(),
nullable
=
False
),
sa
.
Column
(
'user_id'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
'base_model_id'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
'name'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
'params'
,
apps
.
webui
.
internal
.
db
.
JSONField
(),
nullable
=
True
),
sa
.
Column
(
'meta'
,
apps
.
webui
.
internal
.
db
.
JSONField
(),
nullable
=
True
),
sa
.
Column
(
'updated_at'
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
Column
(
'created_at'
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
'id'
)
)
if
"prompt"
not
in
existing_tables
:
op
.
create_table
(
'prompt'
,
sa
.
Column
(
'command'
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
'user_id'
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
'title'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
'content'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
'timestamp'
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
'command'
)
)
if
"tag"
not
in
existing_tables
:
op
.
create_table
(
'tag'
,
sa
.
Column
(
'id'
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
'name'
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
'user_id'
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
'data'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
'id'
)
)
if
"tool"
not
in
existing_tables
:
op
.
create_table
(
'tool'
,
sa
.
Column
(
'id'
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
'user_id'
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
'name'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
'content'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
'specs'
,
apps
.
webui
.
internal
.
db
.
JSONField
(),
nullable
=
True
),
sa
.
Column
(
'meta'
,
apps
.
webui
.
internal
.
db
.
JSONField
(),
nullable
=
True
),
sa
.
Column
(
'valves'
,
apps
.
webui
.
internal
.
db
.
JSONField
(),
nullable
=
True
),
sa
.
Column
(
'updated_at'
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
Column
(
'created_at'
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
'id'
)
)
if
"user"
not
in
existing_tables
:
op
.
create_table
(
'user'
,
sa
.
Column
(
'id'
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
'name'
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
'email'
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
'role'
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
'profile_image_url'
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
'last_active_at'
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
Column
(
'updated_at'
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
Column
(
'created_at'
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
Column
(
'api_key'
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
'settings'
,
apps
.
webui
.
internal
.
db
.
JSONField
(),
nullable
=
True
),
sa
.
Column
(
'info'
,
apps
.
webui
.
internal
.
db
.
JSONField
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
'id'
),
sa
.
UniqueConstraint
(
'api_key'
)
)
# ### end Alembic commands ###
def
downgrade
()
->
None
:
# ### commands auto generated by Alembic - please adjust! ###
op
.
drop_table
(
'user'
)
op
.
drop_table
(
'tool'
)
op
.
drop_table
(
'tag'
)
op
.
drop_table
(
'prompt'
)
op
.
drop_table
(
'model'
)
op
.
drop_table
(
'memory'
)
op
.
drop_table
(
'function'
)
op
.
drop_table
(
'file'
)
op
.
drop_table
(
'document'
)
op
.
drop_table
(
'chatidtag'
)
op
.
drop_table
(
'chat'
)
op
.
drop_table
(
'auth'
)
# ### end Alembic commands ###
backend/migrations/versions/ba76b0bae648_init.py
deleted
100644 → 0
View file @
da403f3e
"""init
Revision ID: ba76b0bae648
Revises:
Create Date: 2024-06-24 09:09:11.636336
"""
from
typing
import
Sequence
,
Union
from
alembic
import
op
import
sqlalchemy
as
sa
import
apps.webui.internal.db
# revision identifiers, used by Alembic.
revision
:
str
=
"ba76b0bae648"
down_revision
:
Union
[
str
,
None
]
=
None
branch_labels
:
Union
[
str
,
Sequence
[
str
],
None
]
=
None
depends_on
:
Union
[
str
,
Sequence
[
str
],
None
]
=
None
def
upgrade
()
->
None
:
# ### commands auto generated by Alembic - please adjust! ###
op
.
create_table
(
"auth"
,
sa
.
Column
(
"id"
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
"email"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"password"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"active"
,
sa
.
Boolean
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
"id"
),
)
op
.
create_table
(
"chat"
,
sa
.
Column
(
"id"
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
"user_id"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"title"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"chat"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"created_at"
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
Column
(
"updated_at"
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
Column
(
"share_id"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"archived"
,
sa
.
Boolean
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
"id"
),
sa
.
UniqueConstraint
(
"share_id"
),
)
op
.
create_table
(
"chatidtag"
,
sa
.
Column
(
"id"
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
"tag_name"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"chat_id"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"user_id"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"timestamp"
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
"id"
),
)
op
.
create_table
(
"document"
,
sa
.
Column
(
"collection_name"
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
"name"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"title"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"filename"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"content"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"user_id"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"timestamp"
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
"collection_name"
),
sa
.
UniqueConstraint
(
"name"
),
)
op
.
create_table
(
"file"
,
sa
.
Column
(
"id"
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
"user_id"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"filename"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"meta"
,
apps
.
webui
.
internal
.
db
.
JSONField
(),
nullable
=
True
),
sa
.
Column
(
"created_at"
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
"id"
),
)
op
.
create_table
(
"function"
,
sa
.
Column
(
"id"
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
"user_id"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"name"
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
"type"
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
"content"
,
sa
.
Text
(),
nullable
=
True
),
sa
.
Column
(
"meta"
,
apps
.
webui
.
internal
.
db
.
JSONField
(),
nullable
=
True
),
sa
.
Column
(
"valves"
,
apps
.
webui
.
internal
.
db
.
JSONField
(),
nullable
=
True
),
sa
.
Column
(
"is_active"
,
sa
.
Boolean
(),
nullable
=
True
),
sa
.
Column
(
"updated_at"
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
Column
(
"created_at"
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
"id"
),
)
op
.
create_table
(
"memory"
,
sa
.
Column
(
"id"
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
"user_id"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"content"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"updated_at"
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
Column
(
"created_at"
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
"id"
),
)
op
.
create_table
(
"model"
,
sa
.
Column
(
"id"
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
"user_id"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"base_model_id"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"name"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"params"
,
apps
.
webui
.
internal
.
db
.
JSONField
(),
nullable
=
True
),
sa
.
Column
(
"meta"
,
apps
.
webui
.
internal
.
db
.
JSONField
(),
nullable
=
True
),
sa
.
Column
(
"updated_at"
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
Column
(
"created_at"
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
"id"
),
)
op
.
create_table
(
"prompt"
,
sa
.
Column
(
"command"
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
"user_id"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"title"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"content"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"timestamp"
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
"command"
),
)
op
.
create_table
(
"tag"
,
sa
.
Column
(
"id"
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
"name"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"user_id"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"data"
,
sa
.
String
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
"id"
),
)
op
.
create_table
(
"tool"
,
sa
.
Column
(
"id"
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
"user_id"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"name"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"content"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"specs"
,
apps
.
webui
.
internal
.
db
.
JSONField
(),
nullable
=
True
),
sa
.
Column
(
"meta"
,
apps
.
webui
.
internal
.
db
.
JSONField
(),
nullable
=
True
),
sa
.
Column
(
"valves"
,
apps
.
webui
.
internal
.
db
.
JSONField
(),
nullable
=
True
),
sa
.
Column
(
"updated_at"
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
Column
(
"created_at"
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
"id"
),
)
op
.
create_table
(
"user"
,
sa
.
Column
(
"id"
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
"name"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"email"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"role"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"profile_image_url"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"last_active_at"
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
Column
(
"updated_at"
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
Column
(
"created_at"
,
sa
.
BigInteger
(),
nullable
=
True
),
sa
.
Column
(
"api_key"
,
sa
.
String
(),
nullable
=
True
),
sa
.
Column
(
"settings"
,
apps
.
webui
.
internal
.
db
.
JSONField
(),
nullable
=
True
),
sa
.
Column
(
"info"
,
apps
.
webui
.
internal
.
db
.
JSONField
(),
nullable
=
True
),
sa
.
PrimaryKeyConstraint
(
"id"
),
sa
.
UniqueConstraint
(
"api_key"
),
)
# ### end Alembic commands ###
def
downgrade
()
->
None
:
# ### commands auto generated by Alembic - please adjust! ###
op
.
drop_table
(
"user"
)
op
.
drop_table
(
"tool"
)
op
.
drop_table
(
"tag"
)
op
.
drop_table
(
"prompt"
)
op
.
drop_table
(
"model"
)
op
.
drop_table
(
"memory"
)
op
.
drop_table
(
"function"
)
op
.
drop_table
(
"file"
)
op
.
drop_table
(
"document"
)
op
.
drop_table
(
"chatidtag"
)
op
.
drop_table
(
"chat"
)
op
.
drop_table
(
"auth"
)
# ### end Alembic commands ###
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment