|
1 | 1 | """empty message |
2 | 2 |
|
3 | | -Revision ID: 850b2c5dc08f |
4 | | -Revises: |
5 | | -Create Date: 2025-06-24 13:24:25.714734 |
| 3 | +Revision ID: 0b274fcc91e2 |
| 4 | +Revises: db9c88848f52 |
| 5 | +Create Date: 2025-07-03 13:32:08.830672 |
6 | 6 |
|
7 | 7 | """ |
8 | 8 | from typing import Sequence, Union |
|
12 | 12 | from pgvector.sqlalchemy import Vector |
13 | 13 |
|
14 | 14 | # revision identifiers, used by Alembic. |
15 | | -revision: str = '850b2c5dc08f' |
16 | | -down_revision: Union[str, None] = None |
| 15 | +revision: str = '0b274fcc91e2' |
| 16 | +down_revision: Union[str, None] = 'db9c88848f52' |
17 | 17 | branch_labels: Union[str, Sequence[str], None] = None |
18 | 18 | depends_on: Union[str, Sequence[str], None] = None |
19 | 19 |
|
@@ -197,40 +197,48 @@ def upgrade() -> None: |
197 | 197 | sa.Column('update_time', sa.DateTime(timezone=True), nullable=False), |
198 | 198 | sa.PrimaryKeyConstraint('id', 'workspace') |
199 | 199 | ) |
200 | | - op.create_table('lightrag_doc_full', |
201 | | - sa.Column('id', sa.String(length=255), nullable=False), |
202 | | - sa.Column('workspace', sa.String(length=255), nullable=False), |
203 | | - sa.Column('doc_name', sa.String(length=1024), nullable=True), |
204 | | - sa.Column('content', sa.Text(), nullable=True), |
205 | | - sa.Column('meta', sa.JSON(), nullable=True), |
206 | | - sa.Column('create_time', sa.DateTime(timezone=True), nullable=False), |
207 | | - sa.Column('update_time', sa.DateTime(timezone=True), nullable=False), |
208 | | - sa.PrimaryKeyConstraint('id', 'workspace') |
209 | | - ) |
210 | | - op.create_table('lightrag_doc_status', |
| 200 | + op.create_table('lightrag_graph_edges', |
| 201 | + sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False), |
| 202 | + sa.Column('source_entity_id', sa.String(length=255), nullable=False), |
| 203 | + sa.Column('target_entity_id', sa.String(length=255), nullable=False), |
| 204 | + sa.Column('weight', sa.Numeric(precision=10, scale=6), nullable=False), |
| 205 | + sa.Column('keywords', sa.Text(), nullable=True), |
| 206 | + sa.Column('description', sa.Text(), nullable=True), |
| 207 | + sa.Column('source_id', sa.Text(), nullable=True), |
| 208 | + sa.Column('file_path', sa.Text(), nullable=True), |
211 | 209 | sa.Column('workspace', sa.String(length=255), nullable=False), |
212 | | - sa.Column('id', sa.String(length=255), nullable=False), |
213 | | - sa.Column('content', sa.Text(), nullable=True), |
214 | | - sa.Column('content_summary', sa.String(length=255), nullable=True), |
215 | | - sa.Column('content_length', sa.Integer(), nullable=True), |
216 | | - sa.Column('chunks_count', sa.Integer(), nullable=True), |
217 | | - sa.Column('status', sa.Enum('pending', 'processing', 'processed', 'failed', name='lightragdocstatus'), nullable=True), |
218 | | - sa.Column('file_path', sa.String(length=512), nullable=True), |
219 | | - sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), |
220 | | - sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False), |
221 | | - sa.PrimaryKeyConstraint('workspace', 'id'), |
222 | | - sa.UniqueConstraint('workspace', 'id', name='uq_lightrag_doc_status_workspace_id') |
| 210 | + sa.Column('createtime', sa.DateTime(timezone=True), nullable=False), |
| 211 | + sa.Column('updatetime', sa.DateTime(timezone=True), nullable=False), |
| 212 | + sa.PrimaryKeyConstraint('id'), |
| 213 | + sa.UniqueConstraint('workspace', 'source_entity_id', 'target_entity_id', name='uq_lightrag_graph_edges_workspace_source_target') |
223 | 214 | ) |
224 | | - op.create_table('lightrag_llm_cache', |
| 215 | + op.create_index('idx_lightrag_edges_degree_calc', 'lightrag_graph_edges', ['workspace', 'source_entity_id', 'target_entity_id', 'weight'], unique=False) |
| 216 | + op.create_index('idx_lightrag_edges_metadata', 'lightrag_graph_edges', ['workspace', 'source_entity_id', 'target_entity_id', 'weight', 'keywords'], unique=False) |
| 217 | + op.create_index('idx_lightrag_edges_weight', 'lightrag_graph_edges', ['workspace', 'weight'], unique=False) |
| 218 | + op.create_index('idx_lightrag_edges_workspace_createtime', 'lightrag_graph_edges', ['workspace', 'createtime'], unique=False) |
| 219 | + op.create_index('idx_lightrag_edges_workspace_source', 'lightrag_graph_edges', ['workspace', 'source_entity_id'], unique=False) |
| 220 | + op.create_index('idx_lightrag_edges_workspace_source_target', 'lightrag_graph_edges', ['workspace', 'source_entity_id', 'target_entity_id'], unique=False) |
| 221 | + op.create_index('idx_lightrag_edges_workspace_target', 'lightrag_graph_edges', ['workspace', 'target_entity_id'], unique=False) |
| 222 | + op.create_index('idx_lightrag_edges_workspace_target_source', 'lightrag_graph_edges', ['workspace', 'target_entity_id', 'source_entity_id'], unique=False) |
| 223 | + op.create_table('lightrag_graph_nodes', |
| 224 | + sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False), |
| 225 | + sa.Column('entity_id', sa.String(length=256), nullable=False), |
| 226 | + sa.Column('entity_name', sa.String(length=255), nullable=True), |
| 227 | + sa.Column('entity_type', sa.String(length=255), nullable=True), |
| 228 | + sa.Column('description', sa.Text(), nullable=True), |
| 229 | + sa.Column('source_id', sa.Text(), nullable=True), |
| 230 | + sa.Column('file_path', sa.Text(), nullable=True), |
225 | 231 | sa.Column('workspace', sa.String(length=255), nullable=False), |
226 | | - sa.Column('id', sa.String(length=255), nullable=False), |
227 | | - sa.Column('mode', sa.String(length=32), nullable=False), |
228 | | - sa.Column('original_prompt', sa.Text(), nullable=True), |
229 | | - sa.Column('return_value', sa.Text(), nullable=True), |
230 | | - sa.Column('create_time', sa.DateTime(timezone=True), nullable=False), |
231 | | - sa.Column('update_time', sa.DateTime(timezone=True), nullable=True), |
232 | | - sa.PrimaryKeyConstraint('workspace', 'id', 'mode') |
| 232 | + sa.Column('createtime', sa.DateTime(timezone=True), nullable=False), |
| 233 | + sa.Column('updatetime', sa.DateTime(timezone=True), nullable=False), |
| 234 | + sa.PrimaryKeyConstraint('id'), |
| 235 | + sa.UniqueConstraint('workspace', 'entity_id', name='uq_lightrag_graph_nodes_workspace_entity') |
233 | 236 | ) |
| 237 | + op.create_index('idx_lightrag_nodes_entity_name', 'lightrag_graph_nodes', ['workspace', 'entity_name'], unique=False) |
| 238 | + op.create_index('idx_lightrag_nodes_entity_type', 'lightrag_graph_nodes', ['workspace', 'entity_type'], unique=False) |
| 239 | + op.create_index('idx_lightrag_nodes_entity_type_createtime', 'lightrag_graph_nodes', ['workspace', 'entity_type', 'createtime'], unique=False) |
| 240 | + op.create_index('idx_lightrag_nodes_workspace_createtime', 'lightrag_graph_nodes', ['workspace', 'createtime'], unique=False) |
| 241 | + op.create_index('idx_lightrag_nodes_workspace_type_id', 'lightrag_graph_nodes', ['workspace', 'entity_type', 'entity_id'], unique=False) |
234 | 242 | op.create_table('lightrag_vdb_entity', |
235 | 243 | sa.Column('id', sa.String(length=255), nullable=False), |
236 | 244 | sa.Column('workspace', sa.String(length=255), nullable=False), |
@@ -391,9 +399,21 @@ def downgrade() -> None: |
391 | 399 | op.drop_table('llm_provider') |
392 | 400 | op.drop_table('lightrag_vdb_relation') |
393 | 401 | op.drop_table('lightrag_vdb_entity') |
394 | | - op.drop_table('lightrag_llm_cache') |
395 | | - op.drop_table('lightrag_doc_status') |
396 | | - op.drop_table('lightrag_doc_full') |
| 402 | + op.drop_index('idx_lightrag_nodes_workspace_type_id', table_name='lightrag_graph_nodes') |
| 403 | + op.drop_index('idx_lightrag_nodes_workspace_createtime', table_name='lightrag_graph_nodes') |
| 404 | + op.drop_index('idx_lightrag_nodes_entity_type_createtime', table_name='lightrag_graph_nodes') |
| 405 | + op.drop_index('idx_lightrag_nodes_entity_type', table_name='lightrag_graph_nodes') |
| 406 | + op.drop_index('idx_lightrag_nodes_entity_name', table_name='lightrag_graph_nodes') |
| 407 | + op.drop_table('lightrag_graph_nodes') |
| 408 | + op.drop_index('idx_lightrag_edges_workspace_target_source', table_name='lightrag_graph_edges') |
| 409 | + op.drop_index('idx_lightrag_edges_workspace_target', table_name='lightrag_graph_edges') |
| 410 | + op.drop_index('idx_lightrag_edges_workspace_source_target', table_name='lightrag_graph_edges') |
| 411 | + op.drop_index('idx_lightrag_edges_workspace_source', table_name='lightrag_graph_edges') |
| 412 | + op.drop_index('idx_lightrag_edges_workspace_createtime', table_name='lightrag_graph_edges') |
| 413 | + op.drop_index('idx_lightrag_edges_weight', table_name='lightrag_graph_edges') |
| 414 | + op.drop_index('idx_lightrag_edges_metadata', table_name='lightrag_graph_edges') |
| 415 | + op.drop_index('idx_lightrag_edges_degree_calc', table_name='lightrag_graph_edges') |
| 416 | + op.drop_table('lightrag_graph_edges') |
397 | 417 | op.drop_table('lightrag_doc_chunks') |
398 | 418 | op.drop_table('invitation') |
399 | 419 | op.drop_index(op.f('ix_document_index_status'), table_name='document_index') |
|
0 commit comments