Coverage for mindsdb / migrations / versions / 2023-09-20_309db3d07cf4_add_knowledge_base.py: 82%

11 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-01-21 00:36 +0000

1"""add knowledge base 

2 

3Revision ID: 309db3d07cf4 

4Revises: 6cb02dfd7f61 

5Create Date: 2023-09-20 13:48:39.422306 

6 

7""" 

8import sqlalchemy as sa 

9from alembic import op 

10 

11import mindsdb.interfaces.storage.db # noqa 

12 

13# revision identifiers, used by Alembic. 

14revision = "309db3d07cf4" 

15down_revision = "6cb02dfd7f61" 

16branch_labels = None 

17depends_on = None 

18 

19 

20def upgrade(): 

21 # ### commands auto generated by Alembic - please adjust! ### 

22 op.create_table( 

23 "knowledge_base", 

24 sa.Column("id", sa.Integer(), nullable=False), 

25 sa.Column("name", sa.String(), nullable=False), 

26 sa.Column("project_id", sa.Integer(), nullable=False), 

27 sa.Column("params", sa.JSON(), nullable=True), 

28 sa.Column("vector_database_id", sa.Integer(), nullable=True), 

29 sa.Column("vector_database_table", sa.String(), nullable=True), 

30 sa.Column("embedding_model_id", sa.Integer(), nullable=True), 

31 sa.Column("created_at", sa.DateTime(), nullable=True), 

32 sa.Column("updated_at", sa.DateTime(), nullable=True), 

33 sa.ForeignKeyConstraint( 

34 ["embedding_model_id"], 

35 ["predictor.id"], 

36 name="fk_knowledge_base_embedding_model_id", 

37 ), 

38 sa.ForeignKeyConstraint( 

39 ["vector_database_id"], 

40 ["integration.id"], 

41 name="fk_knowledge_base_vector_database_id", 

42 ), 

43 sa.PrimaryKeyConstraint("id"), 

44 sa.UniqueConstraint( 

45 "name", "project_id", name="unique_knowledge_base_name_project_id" 

46 ), 

47 ) 

48 # ### end Alembic commands ### 

49 

50 

51def downgrade(): 

52 # ### commands auto generated by Alembic - please adjust! ### 

53 op.drop_table("knowledge_base") 

54 # ### end Alembic commands ###