'Migrate the container schema to support tracking objects from
multiple storage policies.  If the container_stat table has any
pending migrations, they are applied now before copying into
container_info.
* create the \'policy_stat\' table.
* copy the current \'object_count\' and \'bytes_used\' columns to a
row in the \'policy_stat\' table.
* add the storage_policy_index column to the \'object\' table.
* drop the \'object_insert\' and \'object_delete\' triggers.
* add the \'object_insert_policy_stat\' and
\'object_delete_policy_stat\' triggers.
* create container_info table for non-policy container info
* insert values from container_stat into container_info
* drop container_stat table
* create container_stat view'

def _migrate_add_storage_policy(self, conn):

    try:
        self._migrate_add_container_sync_points(conn)
    except sqlite3.OperationalError as e:
        if ('duplicate    column' in str(e)):
            conn.execute('ROLLBACK;')
        else:
            raise
    try:
        conn.executescript("\n                                                                ALTER    TABLE    container_stat\n                                                                ADD    COLUMN    metadata    TEXT    DEFAULT    '';\n                                                ")
    except sqlite3.OperationalError as e:
        if ('duplicate    column' not in str(e)):
            raise
    column_names = ',    '.join(('account', 'container', 'created_at', 'put_timestamp', 'delete_timestamp', 'reported_put_timestamp', 'reported_object_count', 'reported_bytes_used', 'hash', 'id', 'status', 'status_changed_at', 'metadata', 'x_container_sync_point1', 'x_container_sync_point2'))
    conn.executescript(((((((('BEGIN;' + POLICY_STAT_TABLE_CREATE) + '\n                                                                INSERT    INTO    policy_stat    (\n                                                                                storage_policy_index,    object_count,    bytes_used)\n                                                                SELECT    0,    object_count,    bytes_used\n                                                                FROM    container_stat;\n\n                                                                ALTER    TABLE    object\n                                                                ADD    COLUMN    storage_policy_index    INTEGER    DEFAULT    0;\n\n                                                                DROP    TRIGGER    object_insert;\n                                                                DROP    TRIGGER    object_delete;\n                                                ') + POLICY_STAT_TRIGGER_SCRIPT) + CONTAINER_INFO_TABLE_SCRIPT) + ('\n                                                                INSERT    INTO    container_info    (%s)\n                                                                SELECT    %s    FROM    container_stat;\n\n                                                                DROP    TABLE    IF    EXISTS    container_stat;\n                                                ' % (column_names, column_names))) + CONTAINER_STAT_VIEW_SCRIPT) + 'COMMIT;'))
