def startup(self): print "Checking schema for compliance" ## Make sure that the schema conforms dbh = DB.DBO() dbh.execute("select value from meta where property='flag_db'") DB.check_column_in_table(None, 'sql_cache', 'status', 'enum("progress","dirty","cached")') for row in dbh: try: DB.check_column_in_table(row['value'], 'sql_cache', 'status', 'enum("progress","dirty","cached")') except: continue ## Check the schema: dbh.check_index("jobs", "state") DB.check_column_in_table(None, 'jobs', 'priority', 'int default 10') DB.check_column_in_table(None, 'jobs', 'pid', 'int default 0') DB.check_column_in_table(None, 'jobs', 'when_valid', 'TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL') ## Check for the high_priority_jobs table (its basically ## another jobs table for high priority jobs - so workers ## first check this table before the main jobs table). try: dbh.execute("select * from high_priority_jobs limit 1") except: dbh.execute("create table if not exists high_priority_jobs like jobs") ## Schedule the first periodic task: task = Periodic() task.run()