refac
This commit is contained in:
1 parent
1b9d22e324
commit
dc0f8ae6f2
2 files changed
+7
-1
No files matched your search
@@ -93,7 +93,10 @@ def upgrade():
|
|||||||
conn.execute(update_stmt)
|
conn.execute(update_stmt)
|
||||||
|
|
||||||
# Add columns `pinned` and `meta` to 'chat'
|
# Add columns `pinned` and `meta` to 'chat'
|
||||||
|
chat_columns = {c['name'] for c in inspector.get_columns('chat')}
|
||||||
|
if 'pinned' not in chat_columns:
|
||||||
op.add_column('chat', sa.Column('pinned', sa.Boolean(), nullable=True))
|
op.add_column('chat', sa.Column('pinned', sa.Boolean(), nullable=True))
|
||||||
|
if 'meta' not in chat_columns:
|
||||||
op.add_column('chat', sa.Column('meta', sa.JSON(), nullable=False, server_default='{}'))
|
op.add_column('chat', sa.Column('meta', sa.JSON(), nullable=False, server_default='{}'))
|
||||||
|
|
||||||
chatidtag = table('chatidtag', column('chat_id', sa.String()), column('tag_name', sa.String()))
|
chatidtag = table('chatidtag', column('chat_id', sa.String()), column('tag_name', sa.String()))
|
||||||
|
|||||||
@@ -47,7 +47,10 @@ def upgrade():
|
|||||||
# If the column is already JSON, no need to do anything
|
# If the column is already JSON, no need to do anything
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Step 3: Migrate data from 'old_chat' to 'chat'
|
# Step 3: Migrate data from 'old_chat' to 'chat' (only if old_chat exists)
|
||||||
|
# Re-check columns after potential rename above
|
||||||
|
current_cols = {c['name'] for c in inspector.get_columns('chat')}
|
||||||
|
if 'old_chat' in current_cols:
|
||||||
chat_table = table(
|
chat_table = table(
|
||||||
'chat',
|
'chat',
|
||||||
sa.Column('id', sa.String(), primary_key=True),
|
sa.Column('id', sa.String(), primary_key=True),
|
||||||
|
|||||||
Reference in new issue
Block a user