Skip to content

Commit 539ebd1

Browse files
GraphRAG (#291)
* add alembic * graphrag index ref table * submodule * model * model * join alembic * model * model
1 parent d306abc commit 539ebd1

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"""add graphrag index
2+
3+
Revision ID: ab45734be591
4+
Revises: 32f92724c13c
5+
Create Date: 2025-02-27 12:38:55.549604
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 = 'ab45734be591'
14+
down_revision = '32f92724c13c'
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('graphrag_index',
22+
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
23+
sa.Column('organization_id', postgresql.UUID(as_uuid=True), nullable=True),
24+
sa.Column('name', sa.String(), nullable=True),
25+
sa.Column('description', sa.String(), nullable=True),
26+
sa.Column('created_at', sa.DateTime(), nullable=True),
27+
sa.Column('created_by', postgresql.UUID(as_uuid=True), nullable=True),
28+
sa.Column('state', sa.String(), nullable=True),
29+
sa.Column('error', sa.String(), nullable=True),
30+
sa.Column('settings', sa.JSON(), nullable=True),
31+
sa.Column('root_dir', sa.String(), nullable=True),
32+
sa.ForeignKeyConstraint(['created_by'], ['user.id'], ondelete='SET NULL'),
33+
sa.ForeignKeyConstraint(['organization_id'], ['organization.id'], ondelete='CASCADE'),
34+
sa.PrimaryKeyConstraint('id'),
35+
schema='cognition'
36+
)
37+
op.create_index(op.f('ix_cognition_graphrag_index_created_by'), 'graphrag_index', ['created_by'], unique=False, schema='cognition')
38+
op.create_index(op.f('ix_cognition_graphrag_index_organization_id'), 'graphrag_index', ['organization_id'], unique=False, schema='cognition')
39+
# ### end Alembic commands ###
40+
41+
42+
def downgrade():
43+
# ### commands auto generated by Alembic - please adjust! ###
44+
op.drop_index(op.f('ix_cognition_graphrag_index_organization_id'), table_name='graphrag_index', schema='cognition')
45+
op.drop_index(op.f('ix_cognition_graphrag_index_created_by'), table_name='graphrag_index', schema='cognition')
46+
op.drop_table('graphrag_index', schema='cognition')
47+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)