Jump to content

Auto schema/examples

From Wikitech

This page is for examples of check functions:

Check if cul_user column on cu_log table has default value of 0
    default = db.get_columns('cu_log')['cul_user']['COLUMN_DEFAULT']
    return str(default) == '0'
The same as above but only on enwiktionary
    default = db.get_columns('cu_log', 'enwiktionary')['cul_user']['COLUMN_DEFAULT']
    return str(default) == '0'
If revsrc_user column on revsrc table is unsigned (on enwikivoyage only)
    column = db.get_columns('revsrc', 'enwikivoyage')['revsrc_user']
    return 'unsigned' in column['COLUMN_TYPE'].lower()
If cul_user index exists on cu_log table
    return 'cul_user' not in db.get_indexes('cu_log')
Same as above but only on frwikisource
    return 'cul_user' not in db.get_indexes('cu_log', 'frwikisource')
Whether cul_user index on cu_log table is unique
    return db.get_indexes('cu_log')['cul_user']['unique']
If column cul_actor exists in cul_user index on cu_log table
    return 'cul_actor' in db.get_indexes('cu_log')['cul_user']['columns']
If column ft_title exists in flaggedtemplates but skip wikis that don't have flaggedtemplates table
    columns = db.get_columns('flaggedtemplates')
    if not columns:
        return True
    return 'ft_title' not in columns