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