Coverage for /builds/BuildGrid/buildgrid/buildgrid/server/persistence/sql/alembic/versions/38340cc0cfb7_partial_indices.py: 88.89%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

18 statements  

1# Copyright (C) 2020 Bloomberg LP 

2# 

3# Licensed under the Apache License, Version 2.0 (the "License"); 

4# you may not use this file except in compliance with the License. 

5# You may obtain a copy of the License at 

6# 

7# <http://www.apache.org/licenses/LICENSE-2.0> 

8# 

9# Unless required by applicable law or agreed to in writing, software 

10# distributed under the License is distributed on an "AS IS" BASIS, 

11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

12# See the License for the specific language governing permissions and 

13# limitations under the License. 

14 

15"""partial_indices 

16 

17Revision ID: 38340cc0cfb7 

18Revises: 1553978c6e69 

19Create Date: 2020-10-20 08:56:42.559227 

20 

21""" 

22from alembic import op 

23import sqlalchemy as sa 

24 

25 

26# revision identifiers, used by Alembic. 

27revision = '38340cc0cfb7' 

28down_revision = '1553978c6e69' 

29branch_labels = None 

30depends_on = None 

31 

32 

33def upgrade(): 

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

35 dialect = op.get_context().bind.dialect.name 

36 if dialect == "postgresql": 

37 op.create_index('ix_worker_start_timestamp', 

38 'jobs', 

39 ['worker_start_timestamp'], 

40 unique=False, 

41 postgresql_where=sa.text('worker_start_timestamp IS NOT NULL')) 

42 op.create_index('ix_worker_completed_timestamp', 

43 'jobs', 

44 ['worker_completed_timestamp'], 

45 unique=False, 

46 postgresql_where=sa.text('worker_completed_timestamp IS NOT NULL')) 

47 elif dialect == "sqlite": 

48 op.create_index('ix_worker_start_timestamp', 

49 'jobs', 

50 ['worker_start_timestamp'], 

51 unique=False, 

52 sqlite_where=sa.text('worker_start_timestamp IS NOT NULL')) 

53 op.create_index('ix_worker_completed_timestamp', 

54 'jobs', 

55 ['worker_completed_timestamp'], 

56 unique=False, 

57 sqlite_where=sa.text('worker_completed_timestamp IS NOT NULL')) 

58 # ### end Alembic commands ### 

59 

60 

61def downgrade(): 

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

63 op.drop_index('ix_worker_start_timestamp', table_name='jobs') 

64 op.drop_index('ix_worker_completed_timestamp', table_name='jobs') 

65 # ### end Alembic commands ###