This commit is contained in:
Timothy J. Baek 2024-09-06 05:30:16 +02:00
parent bfb12a7851
commit 9fe62fc80d
2 changed files with 30 additions and 31 deletions

View 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)

View File

@ -11,8 +11,8 @@ from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
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
# revision identifiers, used by Alembic.
@ -82,9 +82,7 @@ def upgrade() -> None:
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", open_webui.apps.webui.internal.db.JSONField(), nullable=True
),
sa.Column("meta", JSONField(), nullable=True),
sa.Column("created_at", sa.BigInteger(), nullable=True),
sa.PrimaryKeyConstraint("id"),
)
@ -97,12 +95,8 @@ def upgrade() -> None:
sa.Column("name", sa.Text(), nullable=True),
sa.Column("type", sa.Text(), nullable=True),
sa.Column("content", sa.Text(), 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("meta", JSONField(), nullable=True),
sa.Column("valves", JSONField(), nullable=True),
sa.Column("is_active", sa.Boolean(), nullable=True),
sa.Column("is_global", sa.Boolean(), 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("base_model_id", sa.Text(), nullable=True),
sa.Column("name", sa.Text(), nullable=True),
sa.Column(
"params", open_webui.apps.webui.internal.db.JSONField(), nullable=True
),
sa.Column(
"meta", open_webui.apps.webui.internal.db.JSONField(), nullable=True
),
sa.Column("params", JSONField(), nullable=True),
sa.Column("meta", JSONField(), nullable=True),
sa.Column("updated_at", sa.BigInteger(), nullable=True),
sa.Column("created_at", sa.BigInteger(), nullable=True),
sa.PrimaryKeyConstraint("id"),
@ -167,15 +157,9 @@ def upgrade() -> None:
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", open_webui.apps.webui.internal.db.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("specs", JSONField(), nullable=True),
sa.Column("meta", JSONField(), nullable=True),
sa.Column("valves", JSONField(), nullable=True),
sa.Column("updated_at", sa.BigInteger(), nullable=True),
sa.Column("created_at", sa.BigInteger(), nullable=True),
sa.PrimaryKeyConstraint("id"),
@ -193,12 +177,8 @@ def upgrade() -> None:
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", open_webui.apps.webui.internal.db.JSONField(), nullable=True
),
sa.Column(
"info", open_webui.apps.webui.internal.db.JSONField(), nullable=True
),
sa.Column("settings", JSONField(), nullable=True),
sa.Column("info", JSONField(), nullable=True),
sa.Column("oauth_sub", sa.Text(), nullable=True),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("api_key"),