function migrate_for_current_blog() { $database_version = get_option('podlove_database_version'); for ($i = $database_version + 1; $i <= DATABASE_VERSION; $i++) { \Podlove\run_migrations_for_version($i); update_option('podlove_database_version', $i); } // flush rewrite rules after migrations set_transient('podlove_needs_to_flush_rewrite_rules', true); // purge cache after migrations $cache = \Podlove\Cache\TemplateCache::get_instance(); $cache->setup_purge(); }
* will have these changes too * * - Test the migrations! :) */ namespace Podlove; define(__NAMESPACE__ . '\\DATABASE_VERSION', 18); add_action('init', function () { $database_version = get_option('podlove_database_version'); if ($database_version === false) { // plugin has just been installed update_option('podlove_database_version', DATABASE_VERSION); } elseif ($database_version < DATABASE_VERSION) { // run one or multiple migrations for ($i = $database_version + 1; $i <= DATABASE_VERSION; $i++) { \Podlove\run_migrations_for_version($i); update_option('podlove_database_version', $i); } } }); /** * Find and run migration for given version number. * * @todo move migrations into separate files * * @param int $version */ function run_migrations_for_version($version) { global $wpdb; switch ($version) {