mirror of
https://github.com/langgenius/dify.git
synced 2026-09-08 11:04:27 +08:00
refactor: extract backup table name as module constant
Share backup_table_name between upgrade() and downgrade() functions to avoid duplication and ensure consistency.
This commit is contained in:
parent
e1777d0f09
commit
c35ecf77ca
@ -16,11 +16,13 @@ down_revision = 'b95962a3885c'
|
|||||||
branch_labels = None
|
branch_labels = None
|
||||||
depends_on = None
|
depends_on = None
|
||||||
|
|
||||||
|
# Backup table name for soft-deleted conversations
|
||||||
|
backup_table_name = 'conversations_4f02b6704509_bak'
|
||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
# Create backup table for soft-deleted conversations
|
# Create backup table for soft-deleted conversations
|
||||||
backup_table_name = 'conversations_4f02b6704509_bak'
|
|
||||||
|
|
||||||
# Check if there are any soft-deleted conversations
|
# Check if there are any soft-deleted conversations
|
||||||
result = op.get_bind().execute(sa.text("SELECT COUNT(*) FROM conversations WHERE is_deleted = true"))
|
result = op.get_bind().execute(sa.text("SELECT COUNT(*) FROM conversations WHERE is_deleted = true"))
|
||||||
@ -48,7 +50,6 @@ def downgrade():
|
|||||||
batch_op.add_column(sa.Column('is_deleted', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False))
|
batch_op.add_column(sa.Column('is_deleted', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False))
|
||||||
|
|
||||||
# Restore soft-deleted conversations from backup table if it exists
|
# Restore soft-deleted conversations from backup table if it exists
|
||||||
backup_table_name = 'conversations_4f02b6704509_bak'
|
|
||||||
|
|
||||||
# Check if backup table exists
|
# Check if backup table exists
|
||||||
result = op.get_bind().execute(sa.text(f"""
|
result = op.get_bind().execute(sa.text(f"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user