Coverage for /usr/local/lib/python3.12/site-packages/prefect/server/database/_migrations/versions/sqlite/2023_03_20_194204_422f8ba9541d_add_artifact_idx.py: 77%

13 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-12-05 13:38 +0000

1"""Add index for querying artifacts 

2 

3Revision ID: 422f8ba9541d 

4Revises: b9aafc3ab936 

5Create Date: 2023-03-20 19:42:04.862363 

6 

7""" 

8 

9from alembic import op 1a

10 

11# revision identifiers, used by Alembic. 

12revision = "422f8ba9541d" 1a

13down_revision = "b9aafc3ab936" 1a

14branch_labels = None 1a

15depends_on = None 1a

16 

17 

18def upgrade(): 1a

19 op.execute("PRAGMA foreign_keys=OFF") 1a

20 

21 op.execute( 1a

22 """ 

23 CREATE INDEX IF NOT EXISTS 

24 ix_artifact__key_created_desc 

25 ON artifact_collection (key, created DESC) 

26 """ 

27 ) 

28 op.execute("PRAGMA foreign_keys=ON") 1a

29 

30 

31def downgrade(): 1a

32 op.execute("PRAGMA foreign_keys=OFF") 

33 

34 op.execute( 

35 """ 

36 DROP INDEX IF EXISTS 

37 ix_artifact__key_created_desc 

38 """ 

39 ) 

40 

41 op.execute("PRAGMA foreign_keys=ON")