Exemplo n.º 1
0
        $files_checkpoint->require_time(2);
        $row['aid'] = $map[$row['attach_id']];
        @mkdir(DATA_DIR . '/Utils_Attachment/' . $row['aid']);
        @rename(DATA_DIR . '/Utils_Attachment/' . $row['local'] . '/' . $row['id'], DATA_DIR . '/Utils_Attachment/' . $row['aid'] . '/' . $row['id']);
        DB::Execute('UPDATE utils_attachment_file SET attach_id=%d WHERE id=%d', array($row['aid'], $row['id']));
        $files_checkpoint->set('files', $files);
    }
    $files_checkpoint->done();
}
Patch::set_message('Updating database');
$new_fk_checkpoint = Patch::checkpoint('create_new_fk');
if (!$new_fk_checkpoint->is_done()) {
    Patch::require_time(5);
    if (DB::is_mysql()) {
        DB::Execute('ALTER TABLE utils_attachment_file ADD FOREIGN KEY (attach_id) REFERENCES utils_attachment_data_1(id)');
    } else {
        DB::Execute('ALTER TABLE utils_attachment_file ADD CONSTRAINT attach_id_fk FOREIGN KEY (attach_id) REFERENCES utils_attachment_data_1');
    }
    $new_fk_checkpoint->done();
}
Patch::set_message('Finishing');
$cleanup_checkpoint = Patch::checkpoint('cleanup');
if (!$cleanup_checkpoint->is_done()) {
    Patch::require_time(3);
    DB::DropTable('utils_attachment_note');
    DB::DropTable('utils_attachment_link');
    Utils_RecordBrowserCommon::enable_watchdog('utils_attachment', array('Utils_AttachmentCommon', 'watchdog_label'));
    $cleanup_checkpoint->done();
}
Utils_WatchdogCommon::dont_notify(false);