Coverage for /builds/BuildGrid/buildgrid/buildgrid/server/sql/alembic/versions/fe3a61461feb_remove_optionals_in_jobs_and_bots_fields.py: 65.62%
32 statements
« prev ^ index » next coverage.py v7.4.1, created at 2024-10-04 17:48 +0000
« prev ^ index » next coverage.py v7.4.1, created at 2024-10-04 17:48 +0000
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.
15"""remove optionals in jobs and bots fields
17Revision ID: fe3a61461feb
18Revises: e83194af8292
19Create Date: 2024-08-30 12:39:10.653746
21"""
22import sqlalchemy as sa
23from alembic import op
24from sqlalchemy.dialects import postgresql
26# revision identifiers, used by Alembic.
27revision = "fe3a61461feb"
28down_revision = "e83194af8292"
29branch_labels = None
30depends_on = None
33def upgrade() -> None:
34 with op.batch_alter_table("jobs") as batch_op:
35 batch_op.alter_column("instance_name", existing_type=sa.VARCHAR(), nullable=False)
36 batch_op.alter_column("action", existing_type=postgresql.BYTEA(), nullable=False)
37 batch_op.alter_column("queued_timestamp", existing_type=postgresql.TIMESTAMP(), nullable=False)
38 batch_op.alter_column("assigned", existing_type=sa.BOOLEAN(), nullable=False)
39 batch_op.alter_column("n_tries", existing_type=sa.INTEGER(), nullable=False)
40 batch_op.alter_column("platform_requirements", existing_type=sa.VARCHAR(), nullable=False)
41 batch_op.alter_column("command", existing_type=sa.VARCHAR(), nullable=False)
43 with op.batch_alter_table("bots") as batch_op:
44 batch_op.alter_column("instance_name", existing_type=sa.VARCHAR(), nullable=False)
45 batch_op.alter_column("expiry_time", existing_type=postgresql.TIMESTAMP(), nullable=False)
48def downgrade() -> None:
49 with op.batch_alter_table("jobs") as batch_op:
50 batch_op.alter_column("instance_name", existing_type=sa.VARCHAR(), nullable=True)
51 batch_op.alter_column("action", existing_type=postgresql.BYTEA(), nullable=True)
52 batch_op.alter_column("queued_timestamp", existing_type=postgresql.TIMESTAMP(), nullable=True)
53 batch_op.alter_column("assigned", existing_type=sa.BOOLEAN(), nullable=True)
54 batch_op.alter_column("n_tries", existing_type=sa.INTEGER(), nullable=True)
55 batch_op.alter_column("platform_requirements", existing_type=sa.VARCHAR(), nullable=True)
56 batch_op.alter_column("command", existing_type=sa.VARCHAR(), nullable=True)
58 with op.batch_alter_table("bots") as batch_op:
59 batch_op.alter_column("instance_name", existing_type=sa.VARCHAR(), nullable=True)
60 batch_op.alter_column("expiry_time", existing_type=postgresql.TIMESTAMP(), nullable=True)