Skip to content

Commit a197c72

Browse files
Chat Sharing (#360)
* alembic * alembic merge * alembic * model * model
1 parent 980bbad commit a197c72

File tree

3 files changed

+92
-1
lines changed

3 files changed

+92
-1
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"""Add conversation shares
2+
3+
Revision ID: 77f1ea22a633
4+
Revises: 199a0d8aefbe
5+
Create Date: 2025-10-30 10:01:12.869034
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
from sqlalchemy.dialects import postgresql
11+
12+
# revision identifiers, used by Alembic.
13+
revision = '77f1ea22a633'
14+
down_revision = '199a0d8aefbe'
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
op.create_table('conversation_global_share',
22+
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
23+
sa.Column('conversation_id', postgresql.UUID(as_uuid=True), nullable=False),
24+
sa.Column('shared_by', postgresql.UUID(as_uuid=True), nullable=False),
25+
sa.Column('created_at', sa.DateTime(), nullable=True),
26+
sa.ForeignKeyConstraint(['conversation_id'], ['cognition.conversation.id'], ondelete='CASCADE'),
27+
sa.ForeignKeyConstraint(['shared_by'], ['user.id'], ondelete='CASCADE'),
28+
sa.PrimaryKeyConstraint('id'),
29+
schema='cognition'
30+
)
31+
op.create_index(op.f('ix_cognition_conversation_global_share_conversation_id'), 'conversation_global_share', ['conversation_id'], unique=False, schema='cognition')
32+
op.create_index(op.f('ix_cognition_conversation_global_share_shared_by'), 'conversation_global_share', ['shared_by'], unique=False, schema='cognition')
33+
op.create_table('conversation_share',
34+
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
35+
sa.Column('conversation_id', postgresql.UUID(as_uuid=True), nullable=False),
36+
sa.Column('shared_with', postgresql.UUID(as_uuid=True), nullable=False),
37+
sa.Column('shared_by', postgresql.UUID(as_uuid=True), nullable=False),
38+
sa.Column('can_copy', sa.Boolean(), nullable=True),
39+
sa.Column('created_at', sa.DateTime(), nullable=True),
40+
sa.ForeignKeyConstraint(['conversation_id'], ['cognition.conversation.id'], ondelete='CASCADE'),
41+
sa.ForeignKeyConstraint(['shared_by'], ['user.id'], ondelete='CASCADE'),
42+
sa.ForeignKeyConstraint(['shared_with'], ['user.id'], ondelete='CASCADE'),
43+
sa.PrimaryKeyConstraint('id'),
44+
schema='cognition'
45+
)
46+
op.create_index(op.f('ix_cognition_conversation_share_conversation_id'), 'conversation_share', ['conversation_id'], unique=False, schema='cognition')
47+
op.create_index(op.f('ix_cognition_conversation_share_shared_by'), 'conversation_share', ['shared_by'], unique=False, schema='cognition')
48+
op.create_index(op.f('ix_cognition_conversation_share_shared_with'), 'conversation_share', ['shared_with'], unique=False, schema='cognition')
49+
# ### end Alembic commands ###
50+
51+
52+
def downgrade():
53+
# ### commands auto generated by Alembic - please adjust! ###
54+
op.drop_index(op.f('ix_cognition_conversation_share_shared_with'), table_name='conversation_share', schema='cognition')
55+
op.drop_index(op.f('ix_cognition_conversation_share_shared_by'), table_name='conversation_share', schema='cognition')
56+
op.drop_index(op.f('ix_cognition_conversation_share_conversation_id'), table_name='conversation_share', schema='cognition')
57+
op.drop_table('conversation_share', schema='cognition')
58+
op.drop_index(op.f('ix_cognition_conversation_global_share_shared_by'), table_name='conversation_global_share', schema='cognition')
59+
op.drop_index(op.f('ix_cognition_conversation_global_share_conversation_id'), table_name='conversation_global_share', schema='cognition')
60+
op.drop_table('conversation_global_share', schema='cognition')
61+
# ### end Alembic commands ###
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""add project conv share settings
2+
3+
Revision ID: 85bb3ebee137
4+
Revises: 77f1ea22a633
5+
Create Date: 2025-11-03 12:55:02.413126
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
12+
# revision identifiers, used by Alembic.
13+
revision = '85bb3ebee137'
14+
down_revision = '77f1ea22a633'
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
op.add_column('project', sa.Column('allow_conversation_sharing_organization', sa.Boolean(), nullable=True), schema='cognition')
22+
op.add_column('project', sa.Column('allow_conversation_sharing_global', sa.Boolean(), nullable=True), schema='cognition')
23+
# ### end Alembic commands ###
24+
25+
26+
def downgrade():
27+
# ### commands auto generated by Alembic - please adjust! ###
28+
op.drop_column('project', 'allow_conversation_sharing_global', schema='cognition')
29+
op.drop_column('project', 'allow_conversation_sharing_organization', schema='cognition')
30+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)