This commit is contained in:
Timothy Jaeryang Baek committed 2026-05-14 13:45:59 +09:00
1 parent 98d3b23085
commit 1b9d22e324
2 files changed
+23 -7

No files matched your search

@@ -20,7 +20,12 @@ depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None: def upgrade() -> None:
conn = op.get_bind()
inspector = sa.inspect(conn)
# Add message_id column to channel_file table # Add message_id column to channel_file table
cf_cols = {c['name'] for c in inspector.get_columns('channel_file')}
if 'message_id' not in cf_cols:
with op.batch_alter_table('channel_file', schema=None) as batch_op: with op.batch_alter_table('channel_file', schema=None) as batch_op:
batch_op.add_column( batch_op.add_column(
sa.Column( sa.Column(
@@ -32,6 +37,8 @@ def upgrade() -> None:
) )
# Add data column to knowledge table # Add data column to knowledge table
k_cols = {c['name'] for c in inspector.get_columns('knowledge')}
if 'data' not in k_cols:
with op.batch_alter_table('knowledge', schema=None) as batch_op: with op.batch_alter_table('knowledge', schema=None) as batch_op:
batch_op.add_column(sa.Column('data', sa.JSON(), nullable=True)) batch_op.add_column(sa.Column('data', sa.JSON(), nullable=True))
@@ -20,23 +20,36 @@ depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None: def upgrade() -> None:
conn = op.get_bind()
inspector = sa.inspect(conn)
existing_tables = set(inspector.get_table_names())
# Update 'channel' table # Update 'channel' table
channel_cols = {c['name'] for c in inspector.get_columns('channel')}
if 'is_private' not in channel_cols:
op.add_column('channel', sa.Column('is_private', sa.Boolean(), nullable=True)) op.add_column('channel', sa.Column('is_private', sa.Boolean(), nullable=True))
if 'archived_at' not in channel_cols:
op.add_column('channel', sa.Column('archived_at', sa.BigInteger(), nullable=True)) op.add_column('channel', sa.Column('archived_at', sa.BigInteger(), nullable=True))
if 'archived_by' not in channel_cols:
op.add_column('channel', sa.Column('archived_by', sa.Text(), nullable=True)) op.add_column('channel', sa.Column('archived_by', sa.Text(), nullable=True))
if 'deleted_at' not in channel_cols:
op.add_column('channel', sa.Column('deleted_at', sa.BigInteger(), nullable=True)) op.add_column('channel', sa.Column('deleted_at', sa.BigInteger(), nullable=True))
if 'deleted_by' not in channel_cols:
op.add_column('channel', sa.Column('deleted_by', sa.Text(), nullable=True)) op.add_column('channel', sa.Column('deleted_by', sa.Text(), nullable=True))
if 'updated_by' not in channel_cols:
op.add_column('channel', sa.Column('updated_by', sa.Text(), nullable=True)) op.add_column('channel', sa.Column('updated_by', sa.Text(), nullable=True))
# Update 'channel_member' table # Update 'channel_member' table
cm_cols = {c['name'] for c in inspector.get_columns('channel_member')}
if 'role' not in cm_cols:
op.add_column('channel_member', sa.Column('role', sa.Text(), nullable=True)) op.add_column('channel_member', sa.Column('role', sa.Text(), nullable=True))
if 'invited_by' not in cm_cols:
op.add_column('channel_member', sa.Column('invited_by', sa.Text(), nullable=True)) op.add_column('channel_member', sa.Column('invited_by', sa.Text(), nullable=True))
if 'invited_at' not in cm_cols:
op.add_column('channel_member', sa.Column('invited_at', sa.BigInteger(), nullable=True)) op.add_column('channel_member', sa.Column('invited_at', sa.BigInteger(), nullable=True))
# Create 'channel_webhook' table # Create 'channel_webhook' table
if 'channel_webhook' not in existing_tables:
op.create_table( op.create_table(
'channel_webhook', 'channel_webhook',
sa.Column('id', sa.Text(), primary_key=True, unique=True, nullable=False), sa.Column('id', sa.Text(), primary_key=True, unique=True, nullable=False),
@@ -55,8 +68,6 @@ def upgrade() -> None:
sa.Column('updated_at', sa.BigInteger(), nullable=False), sa.Column('updated_at', sa.BigInteger(), nullable=False),
) )
pass
def downgrade() -> None: def downgrade() -> None:
# Downgrade 'channel' table # Downgrade 'channel' table
@@ -74,5 +85,3 @@ def downgrade() -> None:
# Drop 'channel_webhook' table # Drop 'channel_webhook' table
op.drop_table('channel_webhook') op.drop_table('channel_webhook')
pass