mirror of
https://github.com/langgenius/dify.git
synced 2026-01-14 06:07:33 +08:00
Some checks are pending
autofix.ci / autofix (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Waiting to run
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Blocked by required conditions
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Blocked by required conditions
Main CI Pipeline / Check Changed Files (push) Waiting to run
Main CI Pipeline / API Tests (push) Blocked by required conditions
Main CI Pipeline / Web Tests (push) Blocked by required conditions
Main CI Pipeline / Style Check (push) Waiting to run
Main CI Pipeline / VDB Tests (push) Blocked by required conditions
Main CI Pipeline / DB Migration Test (push) Blocked by required conditions
Co-authored-by: -LAN- <laipz8200@outlook.com>
63 lines
3.0 KiB
Python
63 lines
3.0 KiB
Python
"""add created by role
|
|
|
|
Revision ID: 9f4e3427ea84
|
|
Revises: 64b051264f32
|
|
Create Date: 2023-05-17 17:29:01.060435
|
|
|
|
"""
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
|
|
def _is_pg(conn):
|
|
return conn.dialect.name == "postgresql"
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '9f4e3427ea84'
|
|
down_revision = '64b051264f32'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
conn = op.get_bind()
|
|
|
|
if _is_pg(conn):
|
|
with op.batch_alter_table('pinned_conversations', schema=None) as batch_op:
|
|
batch_op.add_column(sa.Column('created_by_role', sa.String(length=255), server_default=sa.text("'end_user'::character varying"), nullable=False))
|
|
batch_op.drop_index('pinned_conversation_conversation_idx')
|
|
batch_op.create_index('pinned_conversation_conversation_idx', ['app_id', 'conversation_id', 'created_by_role', 'created_by'], unique=False)
|
|
|
|
with op.batch_alter_table('saved_messages', schema=None) as batch_op:
|
|
batch_op.add_column(sa.Column('created_by_role', sa.String(length=255), server_default=sa.text("'end_user'::character varying"), nullable=False))
|
|
batch_op.drop_index('saved_message_message_idx')
|
|
batch_op.create_index('saved_message_message_idx', ['app_id', 'message_id', 'created_by_role', 'created_by'], unique=False)
|
|
else:
|
|
with op.batch_alter_table('pinned_conversations', schema=None) as batch_op:
|
|
batch_op.add_column(sa.Column('created_by_role', sa.String(length=255), server_default=sa.text("'end_user'"), nullable=False))
|
|
batch_op.drop_index('pinned_conversation_conversation_idx')
|
|
batch_op.create_index('pinned_conversation_conversation_idx', ['app_id', 'conversation_id', 'created_by_role', 'created_by'], unique=False)
|
|
|
|
with op.batch_alter_table('saved_messages', schema=None) as batch_op:
|
|
batch_op.add_column(sa.Column('created_by_role', sa.String(length=255), server_default=sa.text("'end_user'"), nullable=False))
|
|
batch_op.drop_index('saved_message_message_idx')
|
|
batch_op.create_index('saved_message_message_idx', ['app_id', 'message_id', 'created_by_role', 'created_by'], unique=False)
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table('saved_messages', schema=None) as batch_op:
|
|
batch_op.drop_index('saved_message_message_idx')
|
|
batch_op.create_index('saved_message_message_idx', ['app_id', 'message_id', 'created_by'], unique=False)
|
|
batch_op.drop_column('created_by_role')
|
|
|
|
with op.batch_alter_table('pinned_conversations', schema=None) as batch_op:
|
|
batch_op.drop_index('pinned_conversation_conversation_idx')
|
|
batch_op.create_index('pinned_conversation_conversation_idx', ['app_id', 'conversation_id', 'created_by'], unique=False)
|
|
batch_op.drop_column('created_by_role')
|
|
|
|
# ### end Alembic commands ###
|