This commit is contained in:
Timothy Jaeryang Baek committed 2026-05-14 13:46:23 +09:00
1 parent dc0f8ae6f2
commit ee3b14233a
2 files changed
+17

No files matched your search

@@ -16,7 +16,13 @@ depends_on = None
def upgrade(): def upgrade():
conn = op.get_bind()
inspector = sa.inspect(conn)
existing_tables = set(inspector.get_table_names())
# Add 'type' column to the 'channel' table # Add 'type' column to the 'channel' table
channel_cols = {c['name'] for c in inspector.get_columns('channel')}
if 'type' not in channel_cols:
op.add_column( op.add_column(
'channel', 'channel',
sa.Column( sa.Column(
@@ -27,11 +33,14 @@ def upgrade():
) )
# Add 'parent_id' column to the 'message' table for threads # Add 'parent_id' column to the 'message' table for threads
message_cols = {c['name'] for c in inspector.get_columns('message')}
if 'parent_id' not in message_cols:
op.add_column( op.add_column(
'message', 'message',
sa.Column('parent_id', sa.Text(), nullable=True), sa.Column('parent_id', sa.Text(), nullable=True),
) )
if 'message_reaction' not in existing_tables:
op.create_table( op.create_table(
'message_reaction', 'message_reaction',
sa.Column('id', sa.Text(), nullable=False, primary_key=True, unique=True), # Unique reaction ID sa.Column('id', sa.Text(), nullable=False, primary_key=True, unique=True), # Unique reaction ID
@@ -41,6 +50,7 @@ def upgrade():
sa.Column('created_at', sa.BigInteger(), nullable=True), # Timestamp of when the reaction was added sa.Column('created_at', sa.BigInteger(), nullable=True), # Timestamp of when the reaction was added
) )
if 'channel_member' not in existing_tables:
op.create_table( op.create_table(
'channel_member', 'channel_member',
sa.Column('id', sa.Text(), nullable=False, primary_key=True, unique=True), # Record ID for the membership row sa.Column('id', sa.Text(), nullable=False, primary_key=True, unique=True), # Record ID for the membership row
@@ -22,6 +22,13 @@ 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())
if 'group_member' in existing_tables:
return # Already created — skip everything
# 1. Create new table # 1. Create new table
op.create_table( op.create_table(
'group_member', 'group_member',