Coverage for /builds/BuildGrid/buildgrid/buildgrid/server/sql/alembic/versions/afa46425330d_add_platform_properties_table.py: 84.62%

13 statements  

« prev     ^ index     » next       coverage.py v7.4.1, created at 2024-10-04 17:48 +0000

1# Copyright (C) 2023 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"""Add platform properties table 

16 

17Revision ID: afa46425330d 

18Revises: 9b595964dc25 

19Create Date: 2023-10-05 17:08:45.628326 

20 

21""" 

22import sqlalchemy as sa 

23from alembic import op 

24 

25# revision identifiers, used by Alembic. 

26revision = "afa46425330d" 

27down_revision = "9b595964dc25" 

28branch_labels = None 

29depends_on = None 

30 

31 

32def upgrade() -> None: 

33 op.create_table( 

34 "platform_properties", 

35 sa.Column("id", sa.Integer(), autoincrement=True, nullable=False), 

36 sa.Column("key", sa.String(), nullable=True), 

37 sa.Column("value", sa.String(), nullable=True), 

38 sa.PrimaryKeyConstraint("id"), 

39 sa.UniqueConstraint("key", "value"), 

40 ) 

41 op.create_table( 

42 "job_platforms", 

43 sa.Column("job_name", sa.String(), nullable=False), 

44 sa.Column("platform_id", sa.Integer(), nullable=False), 

45 sa.ForeignKeyConstraint( 

46 ["job_name"], 

47 ["jobs.name"], 

48 ), 

49 sa.ForeignKeyConstraint( 

50 ["platform_id"], 

51 ["platform_properties.id"], 

52 ), 

53 sa.PrimaryKeyConstraint("job_name", "platform_id"), 

54 ) 

55 

56 

57def downgrade() -> None: 

58 op.drop_table("job_platforms") 

59 op.drop_table("platform_properties")