lin
2025-07-30 fcd736bf35fd93b563e9bbf594f2aa7b62028cc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from autotest_lib.client.common_lib import global_config
 
def migrate_up(manager):
    # Add the column with a default first, and then drop the default.
    # We cannot add the column, populate the values, and then specify NOT NULL
    # because a record added while this is executing could enter a null value
    # into the table before NOT NULL is specified.
    manager.execute(ADD_COLUMN)
    manager.execute(DROP_DEFAULT)
 
def migrate_down(manager):
    manager.execute(DROP_COLUMN)
 
job_timeout_default = global_config.global_config.get_config_value(
    'AUTOTEST_WEB', 'job_timeout_default')
ADD_COLUMN = ('ALTER TABLE jobs ADD COLUMN timeout INT NOT NULL DEFAULT %s'
              % job_timeout_default)
DROP_DEFAULT = 'ALTER TABLE jobs ALTER COLUMN timeout DROP DEFAULT'
DROP_COLUMN = 'ALTER TABLE jobs DROP COLUMN timeout'