From 12062a544036e29b7276d3736322eecb91017313 Mon Sep 17 00:00:00 2001 From: Mark Date: Fri, 6 Feb 2026 17:27:16 +0800 Subject: [PATCH] [add] migration script --- .../versions/bab823f7cc82_202602061730.py | 52 +++++++++++++++++++ redbear-mem-benchmark | 2 +- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 api/migrations/versions/bab823f7cc82_202602061730.py diff --git a/api/migrations/versions/bab823f7cc82_202602061730.py b/api/migrations/versions/bab823f7cc82_202602061730.py new file mode 100644 index 00000000..9e23fc49 --- /dev/null +++ b/api/migrations/versions/bab823f7cc82_202602061730.py @@ -0,0 +1,52 @@ +"""202602061730 + +Revision ID: bab823f7cc82 +Revises: ef0787b85c35 +Create Date: 2026-02-06 17:24:48.600823 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision: str = 'bab823f7cc82' +down_revision: Union[str, None] = 'ef0787b85c35' +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.drop_table('model_api_keys_backup_20260123') + op.add_column('end_users', sa.Column('memory_config_id', sa.UUID(), nullable=True, comment='关联的记忆配置ID')) + op.create_index(op.f('ix_end_users_memory_config_id'), 'end_users', ['memory_config_id'], unique=False) + op.create_foreign_key(None, 'end_users', 'memory_config', ['memory_config_id'], ['config_id']) + op.add_column('memory_config', sa.Column('is_default', sa.Boolean(), nullable=True, comment='是否为工作空间默认配置')) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('memory_config', 'is_default') + op.drop_constraint(None, 'end_users', type_='foreignkey') + op.drop_index(op.f('ix_end_users_memory_config_id'), table_name='end_users') + op.drop_column('end_users', 'memory_config_id') + op.create_table('model_api_keys_backup_20260123', + sa.Column('id', sa.UUID(), autoincrement=False, nullable=True), + sa.Column('model_name', sa.VARCHAR(), autoincrement=False, nullable=True), + sa.Column('provider', sa.VARCHAR(), autoincrement=False, nullable=True), + sa.Column('api_key', sa.VARCHAR(), autoincrement=False, nullable=True), + sa.Column('api_base', sa.VARCHAR(), autoincrement=False, nullable=True), + sa.Column('config', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True), + sa.Column('usage_count', sa.VARCHAR(), autoincrement=False, nullable=True), + sa.Column('last_used_at', postgresql.TIMESTAMP(precision=6), autoincrement=False, nullable=True), + sa.Column('is_active', sa.BOOLEAN(), autoincrement=False, nullable=True), + sa.Column('priority', sa.VARCHAR(), autoincrement=False, nullable=True), + sa.Column('created_at', postgresql.TIMESTAMP(precision=6), autoincrement=False, nullable=True), + sa.Column('updated_at', postgresql.TIMESTAMP(precision=6), autoincrement=False, nullable=True), + sa.Column('model_config_id', sa.UUID(), autoincrement=False, nullable=True) + ) + # ### end Alembic commands ### diff --git a/redbear-mem-benchmark b/redbear-mem-benchmark index 0c4bcafb..4b0257bb 160000 --- a/redbear-mem-benchmark +++ b/redbear-mem-benchmark @@ -1 +1 @@ -Subproject commit 0c4bcafbc10c89327a9da81a768ef40ddda5c8dc +Subproject commit 4b0257bb4e7dc384b2aaf849b0bd6eae4b39835d