Coverage for mindsdb / migrations / versions / 2023-12-25_4b3c9d63e89c_predictor_index.py: 33%

24 statements  

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

1"""predictor_index 

2 

3Revision ID: 4b3c9d63e89c 

4Revises: c67822e96833 

5Create Date: 2023-12-25 20:50:08.275299 

6 

7""" 

8from alembic import op 

9import sqlalchemy as sa # noqa 

10 

11 

12# revision identifiers, used by Alembic. 

13revision = '4b3c9d63e89c' 

14down_revision = 'c67822e96833' 

15branch_labels = None 

16depends_on = None 

17 

18 

19def upgrade(): 

20 with op.batch_alter_table('agent_skills', schema=None) as batch_op: 

21 try: 

22 batch_op.create_foreign_key('agent_skills_agent_id_fk', 'agents', ['agent_id'], ['id']) 

23 batch_op.create_foreign_key('agent_skills_skill_id_fk', 'skills', ['skill_id'], ['id']) 

24 except Exception: 

25 pass 

26 

27 with op.batch_alter_table('predictor', schema=None) as batch_op: 

28 batch_op.create_index( 

29 'predictor_index', 

30 ['company_id', 'name', 'version', 'active', 'deleted_at'], 

31 unique=True 

32 ) 

33 

34 

35def downgrade(): 

36 with op.batch_alter_table('predictor', schema=None) as batch_op: 

37 batch_op.drop_index('predictor_index') 

38 

39 with op.batch_alter_table('agent_skills', schema=None) as batch_op: 

40 try: 

41 batch_op.drop_constraint('agent_skills_agent_id_fk', type_='foreignkey') 

42 batch_op.drop_constraint('agent_skills_skill_id_fk', type_='foreignkey') 

43 except Exception: 

44 pass