mirror of
https://github.com/open-webui/open-webui
synced 2025-04-15 21:13:44 +00:00
refac
This commit is contained in:
parent
bfb12a7851
commit
9fe62fc80d
19
backend/open_webui/migrations/scripts/revision.py
Normal file
19
backend/open_webui/migrations/scripts/revision.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
from alembic import command
|
||||||
|
from alembic.config import Config
|
||||||
|
|
||||||
|
from open_webui.env import OPEN_WEBUI_DIR
|
||||||
|
|
||||||
|
alembic_cfg = Config(OPEN_WEBUI_DIR / "alembic.ini")
|
||||||
|
|
||||||
|
# Set the script location dynamically
|
||||||
|
migrations_path = OPEN_WEBUI_DIR / "migrations"
|
||||||
|
alembic_cfg.set_main_option("script_location", str(migrations_path))
|
||||||
|
|
||||||
|
|
||||||
|
def revision(message: str) -> None:
|
||||||
|
command.revision(alembic_cfg, message=message, autogenerate=False)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
input_message = input("Enter the revision message: ")
|
||||||
|
revision(input_message)
|
@ -11,8 +11,8 @@ from typing import Sequence, Union
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
import open_webui.apps.webui.internal.db
|
import open_webui.apps.webui.internal.db
|
||||||
|
from open_webui.apps.webui.internal.db import JSONField
|
||||||
from open_webui.migrations.util import get_existing_tables
|
from open_webui.migrations.util import get_existing_tables
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
@ -82,9 +82,7 @@ def upgrade() -> None:
|
|||||||
sa.Column("id", sa.String(), nullable=False),
|
sa.Column("id", sa.String(), nullable=False),
|
||||||
sa.Column("user_id", sa.String(), nullable=True),
|
sa.Column("user_id", sa.String(), nullable=True),
|
||||||
sa.Column("filename", sa.Text(), nullable=True),
|
sa.Column("filename", sa.Text(), nullable=True),
|
||||||
sa.Column(
|
sa.Column("meta", JSONField(), nullable=True),
|
||||||
"meta", open_webui.apps.webui.internal.db.JSONField(), nullable=True
|
|
||||||
),
|
|
||||||
sa.Column("created_at", sa.BigInteger(), nullable=True),
|
sa.Column("created_at", sa.BigInteger(), nullable=True),
|
||||||
sa.PrimaryKeyConstraint("id"),
|
sa.PrimaryKeyConstraint("id"),
|
||||||
)
|
)
|
||||||
@ -97,12 +95,8 @@ def upgrade() -> None:
|
|||||||
sa.Column("name", sa.Text(), nullable=True),
|
sa.Column("name", sa.Text(), nullable=True),
|
||||||
sa.Column("type", sa.Text(), nullable=True),
|
sa.Column("type", sa.Text(), nullable=True),
|
||||||
sa.Column("content", sa.Text(), nullable=True),
|
sa.Column("content", sa.Text(), nullable=True),
|
||||||
sa.Column(
|
sa.Column("meta", JSONField(), nullable=True),
|
||||||
"meta", open_webui.apps.webui.internal.db.JSONField(), nullable=True
|
sa.Column("valves", JSONField(), nullable=True),
|
||||||
),
|
|
||||||
sa.Column(
|
|
||||||
"valves", open_webui.apps.webui.internal.db.JSONField(), nullable=True
|
|
||||||
),
|
|
||||||
sa.Column("is_active", sa.Boolean(), nullable=True),
|
sa.Column("is_active", sa.Boolean(), nullable=True),
|
||||||
sa.Column("is_global", sa.Boolean(), nullable=True),
|
sa.Column("is_global", sa.Boolean(), nullable=True),
|
||||||
sa.Column("updated_at", sa.BigInteger(), nullable=True),
|
sa.Column("updated_at", sa.BigInteger(), nullable=True),
|
||||||
@ -128,12 +122,8 @@ def upgrade() -> None:
|
|||||||
sa.Column("user_id", sa.Text(), nullable=True),
|
sa.Column("user_id", sa.Text(), nullable=True),
|
||||||
sa.Column("base_model_id", sa.Text(), nullable=True),
|
sa.Column("base_model_id", sa.Text(), nullable=True),
|
||||||
sa.Column("name", sa.Text(), nullable=True),
|
sa.Column("name", sa.Text(), nullable=True),
|
||||||
sa.Column(
|
sa.Column("params", JSONField(), nullable=True),
|
||||||
"params", open_webui.apps.webui.internal.db.JSONField(), nullable=True
|
sa.Column("meta", JSONField(), nullable=True),
|
||||||
),
|
|
||||||
sa.Column(
|
|
||||||
"meta", open_webui.apps.webui.internal.db.JSONField(), nullable=True
|
|
||||||
),
|
|
||||||
sa.Column("updated_at", sa.BigInteger(), nullable=True),
|
sa.Column("updated_at", sa.BigInteger(), nullable=True),
|
||||||
sa.Column("created_at", sa.BigInteger(), nullable=True),
|
sa.Column("created_at", sa.BigInteger(), nullable=True),
|
||||||
sa.PrimaryKeyConstraint("id"),
|
sa.PrimaryKeyConstraint("id"),
|
||||||
@ -167,15 +157,9 @@ def upgrade() -> None:
|
|||||||
sa.Column("user_id", sa.String(), nullable=True),
|
sa.Column("user_id", sa.String(), nullable=True),
|
||||||
sa.Column("name", sa.Text(), nullable=True),
|
sa.Column("name", sa.Text(), nullable=True),
|
||||||
sa.Column("content", sa.Text(), nullable=True),
|
sa.Column("content", sa.Text(), nullable=True),
|
||||||
sa.Column(
|
sa.Column("specs", JSONField(), nullable=True),
|
||||||
"specs", open_webui.apps.webui.internal.db.JSONField(), nullable=True
|
sa.Column("meta", JSONField(), nullable=True),
|
||||||
),
|
sa.Column("valves", JSONField(), nullable=True),
|
||||||
sa.Column(
|
|
||||||
"meta", open_webui.apps.webui.internal.db.JSONField(), nullable=True
|
|
||||||
),
|
|
||||||
sa.Column(
|
|
||||||
"valves", open_webui.apps.webui.internal.db.JSONField(), nullable=True
|
|
||||||
),
|
|
||||||
sa.Column("updated_at", sa.BigInteger(), nullable=True),
|
sa.Column("updated_at", sa.BigInteger(), nullable=True),
|
||||||
sa.Column("created_at", sa.BigInteger(), nullable=True),
|
sa.Column("created_at", sa.BigInteger(), nullable=True),
|
||||||
sa.PrimaryKeyConstraint("id"),
|
sa.PrimaryKeyConstraint("id"),
|
||||||
@ -193,12 +177,8 @@ def upgrade() -> None:
|
|||||||
sa.Column("updated_at", sa.BigInteger(), nullable=True),
|
sa.Column("updated_at", sa.BigInteger(), nullable=True),
|
||||||
sa.Column("created_at", sa.BigInteger(), nullable=True),
|
sa.Column("created_at", sa.BigInteger(), nullable=True),
|
||||||
sa.Column("api_key", sa.String(), nullable=True),
|
sa.Column("api_key", sa.String(), nullable=True),
|
||||||
sa.Column(
|
sa.Column("settings", JSONField(), nullable=True),
|
||||||
"settings", open_webui.apps.webui.internal.db.JSONField(), nullable=True
|
sa.Column("info", JSONField(), nullable=True),
|
||||||
),
|
|
||||||
sa.Column(
|
|
||||||
"info", open_webui.apps.webui.internal.db.JSONField(), nullable=True
|
|
||||||
),
|
|
||||||
sa.Column("oauth_sub", sa.Text(), nullable=True),
|
sa.Column("oauth_sub", sa.Text(), nullable=True),
|
||||||
sa.PrimaryKeyConstraint("id"),
|
sa.PrimaryKeyConstraint("id"),
|
||||||
sa.UniqueConstraint("api_key"),
|
sa.UniqueConstraint("api_key"),
|
||||||
|
Loading…
Reference in New Issue
Block a user