refac
This commit is contained in:
1 parent
1004dad274
commit
db2b3d7fd8
3 files changed
+17
-2
No files matched your search
@@ -20,6 +20,11 @@ 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 'channel_file' not in existing_tables:
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'channel_file',
|
'channel_file',
|
||||||
sa.Column('id', sa.Text(), primary_key=True),
|
sa.Column('id', sa.Text(), primary_key=True),
|
||||||
|
|||||||
@@ -16,6 +16,11 @@ depends_on = None
|
|||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
|
conn = op.get_bind()
|
||||||
|
inspector = sa.inspect(conn)
|
||||||
|
file_cols = {c['name'] for c in inspector.get_columns('file')}
|
||||||
|
|
||||||
|
if 'access_control' not in file_cols:
|
||||||
op.add_column(
|
op.add_column(
|
||||||
'file',
|
'file',
|
||||||
sa.Column('access_control', sa.JSON(), nullable=True),
|
sa.Column('access_control', sa.JSON(), nullable=True),
|
||||||
|
|||||||
@@ -56,6 +56,13 @@ def _flush_batch(conn, table, batch):
|
|||||||
|
|
||||||
|
|
||||||
def upgrade() -> None:
|
def upgrade() -> None:
|
||||||
|
conn = op.get_bind()
|
||||||
|
inspector = sa.inspect(conn)
|
||||||
|
existing_tables = set(inspector.get_table_names())
|
||||||
|
|
||||||
|
if 'chat_message' in existing_tables:
|
||||||
|
return # Already created — skip everything
|
||||||
|
|
||||||
# Step 1: Create table
|
# Step 1: Create table
|
||||||
op.create_table(
|
op.create_table(
|
||||||
'chat_message',
|
'chat_message',
|
||||||
@@ -85,8 +92,6 @@ def upgrade() -> None:
|
|||||||
op.create_index('chat_message_user_created_idx', 'chat_message', ['user_id', 'created_at'])
|
op.create_index('chat_message_user_created_idx', 'chat_message', ['user_id', 'created_at'])
|
||||||
|
|
||||||
# Step 2: Backfill from existing chats
|
# Step 2: Backfill from existing chats
|
||||||
conn = op.get_bind()
|
|
||||||
|
|
||||||
chat_table = sa.table(
|
chat_table = sa.table(
|
||||||
'chat',
|
'chat',
|
||||||
sa.column('id', sa.Text()),
|
sa.column('id', sa.Text()),
|
||||||
|
|||||||
Reference in new issue
Block a user