コード例 #1
0
 static function install()
 {
     require_once 'admin/Migrator.php';
     $migrator = new Migrator();
     $migrator->migrate();
     return;
 }
コード例 #2
0
 function synchronizeMedia()
 {
     if (!class_exists('Permissions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php';
     }
     if (!Permissions::getInstance()->check('admin')) {
         $msg = 'Forget IT';
         $this->setRedirect('index.php?option=com_virtuemart', $msg);
     }
     if (!class_exists('Migrator')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'migrator.php';
     }
     $migrator = new Migrator();
     $result = $migrator->portMedia();
     $this->setRedirect(null, $result);
 }
コード例 #3
0
ファイル: Migrator.php プロジェクト: nickl-/php-db-migrations
 private function _connect($host, $user, $pass)
 {
     self::$conn = new mysqli($host, $user, $pass);
     if (self::$conn->connect_errno) {
         throw new Exception(self::$conn->connect_error);
     }
 }
コード例 #4
0
 /**
  * Applies migrations.
  *
  * @param  array  $files
  * @param  string $method
  * @return string|bool
  */
 protected function apply(array $files, $method = 'up')
 {
     $version = false;
     foreach ($files as $version => $file) {
         extract(array_replace($this->migrator->getGlobals(), $this->parameters), EXTR_SKIP);
         $config = (require_once $file);
         if (is_array($config) && isset($config[$method])) {
             $result = call_user_func($config[$method]);
             if (is_string($result)) {
                 return $result;
             }
             if ($result === false) {
                 return $version;
             }
         }
     }
     return $version;
 }
コード例 #5
0
 /**
  * Returns the appropriate config. If it's an old version it updates the config and runs migrations
  * @param  {String}       the version number for Pattern Lab from builder.php
  *
  * @return {Array}        the configuration
  */
 public function getConfig()
 {
     // make sure migrate doesn't happen by default
     $migrate = false;
     $diffVersion = false;
     // double-check the default config file exists
     if (!file_exists($this->plConfigPath)) {
         print "Please make sure config.ini.default exists before trying to have Pattern Lab build the config.ini file automagically.\n";
         exit;
     }
     // set the default config using the pattern lab config
     $config = parse_ini_file($this->plConfigPath);
     $defaultConfig = $config;
     // check to see if the user config exists, if not create it
     print "configuring pattern lab...\n";
     if (!file_exists($this->userConfigPath)) {
         $migrate = true;
     } else {
         $config = parse_ini_file($this->userConfigPath);
     }
     // compare version numbers
     $diffVersion = $config["v"] != $defaultConfig["v"] ? true : false;
     // run an upgrade and migrations if necessary
     if ($migrate || $diffVersion) {
         print "upgrading your version of pattern lab...\n";
         print "checking for migrations...\n";
         $m = new Migrator();
         $m->migrate(true);
         if ($migrate) {
             if (!@copy($this->plConfigPath, $this->userConfigPath)) {
                 print "Please make sure that Pattern Lab can write a new config to config/.\n";
                 exit;
             }
         } else {
             $config = $this->writeNewConfig($config, $defaultConfig);
         }
     }
     return $config;
 }
コード例 #6
0
 function up()
 {
     Migrator::message('inform', 'This migration enables support for uploading files as short URLs.');
     $prefix = DB_PREFIX;
     $t = $this->createTable(DB_PREFIX . 'files');
     $t->column('id', 'serial', array('primary_key' => true, 'null' => false));
     $t->column('title', 'string', array('null' => false));
     $t->column('filepath', 'string', array('null' => false));
     $t->column('type', 'string', array('null' => false, 'default' => 'other'));
     $t->save();
     $this->createIndex(DB_PREFIX . 'files', 'type', 'index_' . DB_PREFIX . 'files_type');
     $this->addColumn(DB_PREFIX . 'urls', 'file_id', 'integer', array('default' => null));
     $this->createIndex(DB_PREFIX . 'urls', 'file_id', 'index_' . DB_PREFIX . 'urls_file_id');
 }
コード例 #7
0
ファイル: media.php プロジェクト: cybershocik/Darek
 function synchronizeMedia()
 {
     $user = JFactory::getUser();
     if ($user->authorise('core.admin', 'com_virtuemart') or $user->authorise('core.manage', 'com_virtuemart')) {
         $configPaths = array('assets_general_path', 'media_category_path', 'media_product_path', 'media_manufacturer_path', 'media_vendor_path');
         foreach ($configPaths as $path) {
             $this->renameFileExtension(VMPATH_ROOT . DS . VmConfig::get($path));
         }
         if (!class_exists('Migrator')) {
             require VMPATH_ADMIN . DS . 'helpers' . DS . 'migrator.php';
         }
         $migrator = new Migrator();
         $result = $migrator->portMedia();
         $this->setRedirect($this->redirectPath, $result);
     } else {
         $msg = 'Forget IT';
         $this->setRedirect('index.php?option=com_virtuemart', $msg);
     }
 }
コード例 #8
0
    function up()
    {
        Migrator::message('inform', 'This migration enables an efficient method of generating automatic slugs.');
        $prefix = DB_PREFIX;
        $t = $this->createTable(DB_PREFIX . 'autoslug');
        $t->column('id', 'serial', array('primary_key' => true, 'null' => false));
        $t->column('method', 'string', array('null' => false, 'size' => '31'));
        $t->column('base10', 'string', array('null' => false, 'size' => '100'));
        $t->save();
        $this->createIndex(DB_PREFIX . 'autoslug', 'method', 'method_index', 'unique');
        // Populate
        // SQLite/PostgreSQL don't support compound(?) inserts.
        // migration could possibly provide an insert function
        $add_methods_sql = array();
        $add_methods_sql[] = <<<EOSQL
INSERT INTO  {$prefix}autoslug (method ,base10)
VALUES ('base36',  '1');
EOSQL;
        $add_methods_sql[] = <<<EOSQL
INSERT INTO  {$prefix}autoslug (method ,base10)
VALUES ('base62',  '1');
EOSQL;
        $add_methods_sql[] = <<<EOSQL
INSERT INTO  {$prefix}autoslug (method ,base10)
VALUES ('mixed-smart',  '1');
EOSQL;
        $add_methods_sql[] = <<<EOSQL
INSERT INTO  {$prefix}autoslug (method ,base10)
VALUES ('smart',  '1');
EOSQL;
        foreach ($add_methods_sql as $sql) {
            $ins = $this->db->prepare($sql);
            if (!$ins->execute()) {
                throw new Exception('Failed to add rows for autoslug methods.');
            }
        }
    }
コード例 #9
0
ファイル: InstallPhoneme.php プロジェクト: PhonemeCms/cms
 public function migrate()
 {
     $this->migrator->setAllServiceProvidersFrom($this->componentsBaseFolder);
     $this->composer->setEnvironment($this->environment);
     $this->migrator->migrateAll();
 }
コード例 #10
0
 function portVmRelatedProducts()
 {
     $this->checkPermissionForTools();
     if (!VmConfig::get('dangeroustools', true)) {
         $msg = $this->_getMsgDangerousTools();
         $this->setRedirect($this->redirectPath, $msg);
         return false;
     }
     $this->storeMigrationOptionsInSession();
     if (!class_exists('Migrator')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'migrator.php';
     }
     $migrator = new Migrator();
     $result = $migrator->portVm1RelatedProducts();
     if ($result) {
         $msg = 'Migration Vm2 related products finished';
     } else {
         $msg = 'Migration was interrupted by max_execution time, please restart';
     }
     $this->setRedirect($this->redirectPath, $msg);
 }
コード例 #11
0
ファイル: install.php プロジェクト: pilot34/lessnmore
<?php

// Prevent anyone for screwing with the database if this file is not here
define('OKAY_TO_MIGRATE', TRUE);
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/-/library');
require_once '-/config.php';
require_once '-/db.php';
require_once 'Migrator.php';
require_once 'QueryTools.php';
if (isset($_GET['start']) and ctype_digit($_GET['start'])) {
    $start = (int) $_GET['start'];
} else {
    $start = NULL;
}
$migrator = new Migrator($db, dirname(__FILE__) . '/-/migrations');
$migrator->migrate($start);
コード例 #12
0
ファイル: index.php プロジェクト: stilliard/rec-migrator
define('PATH', dirname(__FILE__));
require_once PATH . '/Migrator.php';
//
// Handle posted data
//
$error = null;
$userHtml = '';
$convertedHtml = '';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    try {
        // grab the user's post'd html
        $userHtml = isset($_POST['html']) ? $_POST['html'] : null;
        if (!$userHtml) {
            throw new Exception('Please enter some html');
        }
        // convert it
        $convertedHtml = Migrator::convert($userHtml);
    } catch (Exception $e) {
        $error = $e->getMessage();
    }
}
//
// View time
//
// view function to html escape
function escape($string)
{
    return htmlspecialchars($string, ENT_QUOTES, 'utf-8');
}
$view = (object) ['error' => $error, 'userHtml' => $userHtml, 'convertedHtml' => $convertedHtml];
include PATH . '/views/index.php';
コード例 #13
0
 function portVmRelatedProducts()
 {
     $data = JRequest::get('get');
     if (!empty($data['token'])) {
         JRequest::setVar($data['token'], '1', 'post');
     }
     JRequest::checkToken() or jexit('Invalid Token, in ' . JRequest::getWord('task'));
     $this->checkPermissionForTools();
     if (!VmConfig::get('dangeroustools', true)) {
         $msg = $this->_getMsgDangerousTools();
         $this->setRedirect($this->redirectPath, $msg);
         return false;
     }
     $this->storeMigrationOptionsInSession();
     if (!class_exists('Migrator')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'migrator.php';
     }
     $migrator = new Migrator();
     $result = $migrator->portVm1RelatedProducts();
     if ($result) {
         $msg = 'Migration Vm2 related products finished';
     } else {
         $msg = 'Migration was interrupted by max_execution time, please restart';
     }
     $this->setRedirect($this->redirectPath, $msg);
 }
コード例 #14
0
//   if( $version !== '1.6.2' )
//   {
//      echo "<br>You are trying to migrate from TestLink version {$version} " .
//           "<br>this kind of upgrade is NOT AVAILABLE";
//            close_html_and_exit();
//   }
// }
// else
// {
//   echo "<br>Structure of your db_version table seems not OK" .
//        "<br>we are unable to continue";
//   close_html_and_exit();
// }
// // -------------------------------------------------------------------------------
// Create our Migrator Object
$migrate = new Migrator($source_db, $target_db);
if (false == determine_mysql_version($source_db) || false == determine_mysql_version($target_db)) {
    echo "<br /><b>You appear to be using a version of mysql older than version 5 this may not work!</b><br />";
} else {
    echo "<br />mysql version looks ok<br />";
}
// ---TRUNCATE TABLES---
echo '<span>Truncating tables in Testlink 1.7 (target) database. - ' . $db_cfg['target']['db_name'] . ' - </span>';
foreach ($a_sql as $elem) {
    echo "<br />executing query {$elem}";
    $target_db->exec_query($elem);
}
echo '<br />finished truncating tables';
echo "<P><hr>";
// ---STARTING MIGRATION---
echo "<p><b>Please be patient this may take some time!</b><br /><hr /></p>";
コード例 #15
0
ファイル: Formr.php プロジェクト: Metrakit/dynamix
 public function generate($data, $pageId, $order)
 {
     $form = new self();
     $fromObject = false;
     if (is_object($data)) {
         $data = $data->formr();
         $form->i18n_title = NULL;
         $form->i18n_description = NULL;
         $fromObject = true;
     }
     $form->finish_on = $data['method'];
     $form->type = $data['type'];
     $form->save();
     $orderMap = 0;
     foreach ($data['data'] as $dataInput) {
         // Increments the order
         $orderMap++;
         if ($fromObject) {
             $dataInput['title'] = NULL;
             $dataInput['label'] = NULL;
             $dataInput['placeholder'] = NULL;
             $dataInput['helper'] = NULL;
         } else {
             $dataInput['title'] = i18n::add($dataInput['title'], 'title');
             $dataInput['label'] = i18n::add($dataInput['label'], 'label');
             $dataInput['placeholder'] = i18n::add($dataInput['placeholder'], 'placeholder');
             $dataInput['helper'] = i18n::add($dataInput['helper'], 'helper');
         }
         $inputType = InputType::add($dataInput);
         $input = InputView::add($inputType->id, $dataInput);
         // Add options if the input type is a select
         if ($input->name = "select") {
             if (isset($dataInput['options'])) {
                 foreach ($dataInput['options'] as $option) {
                     if ($fromObject) {
                         $option['key'] = NULL;
                         $option['value'] = NULL;
                     } else {
                         $option['key'] = i18n::add($option['key'], 'option_key');
                         $option['value'] = i18n::add($option['value'], 'option_value');
                     }
                     SelectOption::add($input->id, $option);
                 }
             }
         }
         // Add form map
         FormMap::add($input->id, $form->id, $orderMap);
     }
     // Add a block if the form is not by a model
     if (!$fromObject) {
         $block = Block::add($pageId, $order, 'Formr');
         BlockResponsive::add($block->id, 12, 3);
     }
     if ($fromObject) {
         // Add form model
         ModelForm::add($form->id, $data['model']);
     }
     // Generate a migrate file
     if ($form->finish_on == "database") {
         // Prepare migrate content
         $contentMigrate = $this->prepareMigrate($data['data']);
         $bob = new Migrator('form_' . $form->id, $contentMigrate);
         $bob->generate();
     }
     return $form;
 }
コード例 #16
0
 private function runMigration($class)
 {
     $migrator = new Migrator('migrator', Yii::$app);
     $migrator->runSingle($class);
 }
コード例 #17
0
ファイル: migrate.php プロジェクト: lupuxyz/SlimStarter
                $table->increments('id');
                $table->integer('user_id')->unsigned();
                $table->string('ip_address')->nullable();
                $table->integer('attempts')->default(0);
                $table->boolean('suspended')->default(0);
                $table->boolean('banned')->default(0);
                $table->timestamp('last_attempt_at')->nullable();
                $table->timestamp('suspended_at')->nullable();
                $table->timestamp('banned_at')->nullable();
                // We'll need to ensure that MySQL uses the InnoDB engine to
                // support the indexes, other engines aren't affected.
                $table->engine = 'InnoDB';
                $table->index('user_id');
            });
        }
    }
    /**
     * seed the database with initial value
     */
    public function seed()
    {
        try {
            Sentry::createUser(array('email' => '*****@*****.**', 'password' => 'password', 'first_name' => 'Website', 'last_name' => 'Administrator', 'activated' => 1, 'permissions' => array('admin' => 1)));
        } catch (Exception $e) {
            echo $e->getMessage() . "\n";
        }
    }
}
$migrator = new Migrator($config['database']['connections'][$config['database']['default']]);
$migrator->migrate();
$migrator->seed();
コード例 #18
0
 /**
  * Is doing all migrator steps in one row
  *
  * @author Max Milbers
  */
 function migrateAllInOne()
 {
     JRequest::checkToken() or jexit('Invalid Token, in ' . JRequest::getWord('task'));
     $this->checkPermissionForTools();
     if (!VmConfig::get('dangeroustools', true)) {
         $msg = $this->_getMsgDangerousTools();
         $this->setRedirect($this->redirectPath, $msg);
         return false;
     }
     $this->storeMigrationOptionsInSession();
     if (!class_exists('Migrator')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'migrator.php';
     }
     $migrator = new Migrator();
     $result = $migrator->migrateAllInOne();
     $msg = 'Migration finished';
     $this->setRedirect($this->redirectPath, $msg);
 }
コード例 #19
0
    function up()
    {
        Migrator::message('inform', 'This migration will attempt to assign each non-custom/legacy redirection an ' . 'explicit slug (short URL path) equal ' . 'to its id in base 36 (as in the original Lessn).');
        //Set up / mini config
        $batch = 25;
        $prefix = DB_PREFIX;
        $mark_custom = TRUE;
        $db =& $this->db;
        // Queries
        $update_sql = "UPDATE {$prefix}urls SET redir_type = 'custom' WHERE custom_url IS NOT NULL";
        $select_sql = "SELECT * FROM {$prefix}urls " . 'WHERE custom_url IS NULL ' . 'AND id > :min_id ' . 'ORDER BY id ' . 'LIMIT ' . $batch;
        $check_sql = 'SELECT * FROM ' . DB_PREFIX . 'urls WHERE ' . (DB_DRIVER === 'sqlite' ? '' : 'BINARY') . ' custom_url = ' . (DB_DRIVER === 'sqlite' ? '' : 'BINARY') . ' :custom_url';
        $explicit_sql = 'UPDATE ' . DB_PREFIX . 'urls SET custom_url = :custom_url WHERE id=:id LIMIT 1';
        // --- STEP ONE ---
        // Add column to keep track of what kind of migration it is
        try {
            $this->addColumn(DB_PREFIX . 'urls', 'redir_type', 'string', array('default' => 'auto', 'size' => 6, 'null' => false, 'index' => true));
            $this->createIndex(DB_PREFIX . 'urls', 'redir_type', 'redir_type_index');
            Migrator::message('success', 'Added "redir_type" column');
        } catch (Exception $e) {
            Migrator::message('failure', '"redir_type" column already exists… continuing…');
            $mark_custom = FALSE;
        }
        // --- STEP TWO ---
        // SET type to 'custom' when it was really custom
        if ($mark_custom) {
            $updt = $db->prepare($update_sql);
            if (!$updt->execute()) {
                throw new Exception('Update failed!');
            }
            $affected = $updt->rowCount();
            Migrator::message($affected ? 'success' : 'inform', $affected . ' redirection(s) with custom slugs were explicitly marked as \'custom\'.');
        }
        // --- STEP THREE ---
        // Give each id-based redirection an explicit slug
        // Avoid doing failed migration rows over and over
        $min_id = -1;
        while (TRUE) {
            set_time_limit(60);
            $slct = $db->prepare($select_sql);
            $slct->execute(array('min_id' => $min_id));
            $rows = $slct->fetchAll(PDO::FETCH_ASSOC);
            $returned = count($rows);
            $errors = 0;
            // Migrate each of these
            foreach ($rows as $row) {
                $id = $row['id'];
                // For next batch
                if ($id > $min_id) {
                    $min_id = $id;
                }
                // Explicit redirection
                $slug = base_convert($id, 10, 36);
                $chk = $db->prepare($check_sql);
                $chk->execute(array('custom_url' => $slug));
                // Check to make sure one doesn't aready exist
                $conflict = $chk->fetch(PDO::FETCH_ASSOC);
                if ($conflict === FALSE) {
                    $expl = $db->prepare($explicit_sql);
                    $expl->execute(array('custom_url' => $slug, 'id' => $id));
                } elseif (is_array($conflict) && isset($conflict['id'])) {
                    Migrator::message('failure', 'Could not give redirect an explicit slug (already in use!). ' . "\nID: " . $id . ". \nAlready-in-use slug: " . $slug . ". \nID of (custom) redirection already using slug: " . $conflict['id']);
                    $errors++;
                } else {
                    throw new Exception('Unexpected database result when 
						checking for pre-existing rows');
                }
            }
            if ($returned - $errors > 0) {
                Migrator::message('success', 'Gave ' . ($returned - $errors) . ' redirections explicit slugs.');
            }
            if ($returned < $batch) {
                // Complete!
                break;
            }
        }
    }
コード例 #20
0
ファイル: media.php プロジェクト: cuongnd/etravelservice
 function synchronizeMedia()
 {
     if (vmAccess::manager('media')) {
         $configPaths = array('assets_general_path', 'media_category_path', 'media_product_path', 'media_manufacturer_path', 'media_vendor_path');
         foreach ($configPaths as $path) {
             $this->renameFileExtension(VMPATH_ROOT . DS . tsmConfig::get($path));
         }
         if (!class_exists('Migrator')) {
             require VMPATH_ADMIN . DS . 'helpers' . DS . 'migrator.php';
         }
         $migrator = new Migrator();
         $result = $migrator->portMedia();
         $this->setRedirect($this->redirectPath, $result);
     } else {
         $msg = 'Forget IT';
         $this->setRedirect('index.php?option=com_tsmart', $msg);
     }
 }
コード例 #21
0
ファイル: web_migrate.php プロジェクト: ratbird/hope
}
$_language_path = init_i18n($_SESSION['_language']);
include 'lib/include/html_head.inc.php';
$path = $GLOBALS['STUDIP_BASE_PATH'] . '/db/migrations';
$verbose = true;
$target = NULL;
FileLock::setDirectory($GLOBALS['TMP_PATH']);
$lock = new FileLock('web-migrate');
if ($lock->isLocked() && Request::int('release_lock')) {
    $lock->release();
}
if (Request::int('target')) {
    $target = (int) Request::int('target');
}
$version = new DBSchemaVersion('studip');
$migrator = new Migrator($path, $version, $verbose);
if (Request::submitted('start')) {
    ob_start();
    set_time_limit(0);
    $lock->lock(array('timestamp' => time(), 'user_id' => $GLOBALS['user']->id));
    $migrator->migrate_to($target);
    $lock->release();
    $announcements = ob_get_clean();
    $message = MessageBox::Success(_("Die Datenbank wurde erfolgreich migriert."), explode("\n", $announcements));
}
$current = $version->get();
$migrations = $migrator->relevant_migrations($target);
$template = $template_factory->open('web_migrate');
$template->set_attribute('current_page', _('Datenbank-Migration'));
$template->set_attribute('current', $current);
$template->set_attribute('target', $target);
コード例 #22
0
 /**
  * migrate plugin to top migration
  *
  * @param integer $plugin_id
  * @return string output from migrator
  */
 public function migratePlugin($plugin_id)
 {
     $plugin_manager = PluginManager::getInstance();
     $plugin = $plugin_manager->getPluginInfoById($plugin_id);
     $basepath = get_config('PLUGINS_PATH');
     $plugindir = $basepath . '/' . $plugin['path'] . '/';
     if (is_dir($plugindir . '/migrations')) {
         $schema_version = new DBSchemaVersion($plugin['name']);
         $migrator = new Migrator($plugindir . '/migrations', $schema_version, true);
         ob_start();
         $migrator->migrate_to(null);
         $log = ob_get_clean();
     }
     return $log;
 }
コード例 #23
0
 function up()
 {
     Migrator::message('inform', 'This migration allows you to set a custom short URL. ' . 'Make sure to get the <strong>NEW</strong> bookmarklets that support this feature!', false);
     $this->addColumn(DB_PREFIX . 'urls', 'custom_url', 'string', array('default' => null, 'size' => 255));
 }
コード例 #24
0
     * name as returned by gettype().
     *
     * Note: this is an addition not defined in JSR-283.
     *
     * @param string $type
     * @return integer
     * @author Karsten Dambekalns <*****@*****.**>
     */
    public static function typeFromType($type)
    {
        switch ($type) {
            case self::STRING:
                return 'string';
                break;
            case self::BOOLEAN:
                return 'boolean';
                break;
            case self::LONG:
                return 'integer';
                break;
            case self::DOUBLE:
                return 'float';
                break;
            case self::DATE:
                return 'DateTime';
                break;
        }
    }
}
$migrator = new Migrator();
$migrator->run($configuration);
コード例 #25
0
ファイル: migrate.php プロジェクト: se7ven214/Kungfuphp.local
<?php

require 'header.php';
?>
<div>
  <ul class="breadcrumb">
    <li>
      <a href="#">Home</a>
    </li>
    <li>
      <a href="#">Migrate Data</a>
    </li>
  </ul>
</div>

<?php 
openBox("Migrate Old Options", "user", 12);
?>
<p>This version of the Ads EZ Plugin for AdSense uses a new data/option model. When the plugin is activated, all the options from previous versions of Easy AdSense, Google AdSense, AdSense Now, Easy Ads, Easy Chitika etc. are detected and copied over to the new options model. If you have made further changes in the old plugin options and would like to migrate them as well, you can do so here.</p>
<p>Note that clicking on the Migrate button does not overwrite existing (already migrated) options. It will only migrate new options created (for instance, by switching to a new theme and running a previous version of one of the afore-mentioned plugins).</p>
<div><a href="?migrate" class="btn btn-primary" title="Migrate " data-toggle="tooltip">Migrate Now</a> </div>
<div class="clearfix">&nbsp;</div>
<?php 
if (isset($_REQUEST['migrate'])) {
    require_once 'Migrator.php';
    $migrator = new Migrator();
    $migrator->migrate(true);
}
closeBox();
include 'promo.php';
require 'footer.php';
コード例 #26
0
ファイル: Migrator.php プロジェクト: pilot34/lessnmore
 function migrate($start = null)
 {
     $this->html_begin();
     if ($start === null) {
         $start = $this->current_version + 1;
     }
     $files = glob($this->migrations_dir . "/*.php");
     $this->db->beginTransaction();
     $highest_version_seen = 0;
     echo '<dl>';
     foreach ($files as $file) {
         include $file;
         $file = basename($file, '.php');
         $class = substr($file, strpos($file, '_') + 1);
         $v = intval(substr($file, 0, strpos($file, '_')));
         if ($highest_version_seen < $v) {
             $highest_version_seen = $v;
         }
         if (!class_exists($class)) {
             echo '</dl>';
             Migrator::message('failure', 'Could not find class: \'' . $class . '\' in migration \'' . $file . "'");
             //no need to escape for html
             $this->html_end();
             exit;
         }
         if ($v < $start || $v <= $this->currentVersion()) {
             continue;
         }
         $m = new $class($this->db);
         try {
             echo '<dt>Running migration ' . htmlspecialchars($class) . '::up to version ' . $v . '</dt><dd>';
             $m->up();
             Migrator::message('success', 'Migration complete. Current schema version: ' . $v);
             $this->updateInfoToVersion($v);
             $this->db->commit();
             $this->db->beginTransaction();
             echo '</dd>';
         } catch (Exception $e) {
             Migrator::message('failure', 'Failed to migrate, rolling back.' . "\n" . (string) $e);
             $this->db->rollBack();
             echo '</dd></dl>';
             $this->html_end();
             exit;
         }
         //$last_version = $v;
     }
     echo '</dl>';
     if ($this->currentVersion() == $highest_version_seen) {
         Migrator::message('inform', 'Your schema is up-to-date! Schema version: ' . $this->currentVersion());
     }
     $this->html_end();
 }
コード例 #27
0
ファイル: migration.php プロジェクト: jaz303/zing
 protected function sources()
 {
     $sources = array('app' => Migrator::application_migration_dir());
     $plugin_manager = \zing\plugin\Manager::instance();
     foreach ($plugin_manager->plugins() as $plugin) {
         if ($plugin->has_migrations()) {
             $sources["plugin.{$plugin->id()}"] = $plugin->migration_path();
         }
     }
     return $sources;
 }