/** * Launch Ruckusing database migrations shell * * Since it's launched in the CakePHP shell you can use all the * CakePHP magic inside the migrations. Super sweet. * * @return void */ function ruckusing() { define('RUCKUSING_BASE', dirname(__FILE__) . DS . '..' . DS . 'ruckusing'); require_once RUCKUSING_BASE . '/lib/classes/util/class.Ruckusing_Logger.php'; require_once RUCKUSING_BASE . '/config/database.inc.php'; require_once RUCKUSING_BASE . '/lib/classes/class.Ruckusing_FrameworkRunner.php'; $argv = $this->args; array_unshift($argv, "vendors/ruckusing/main.php"); $main = new Ruckusing_FrameworkRunner($ruckusing_db_config, $argv); $main->execute(); }
/** * @dataProvider prefixProvider * @param string $prefix */ public function testRevertPrefixedTables($prefix) { $this->config['db']['mysql_test']['prefix'] = $prefix; $this->config['db']['mysql_test']['schema_version_table_name'] = $prefix . 'schema_migrations'; $runner = new Ruckusing_FrameworkRunner($this->config, array(__FILE__, 'ENV=mysql_test', 'db:migrate', 'VERSION=0')); $output = $runner->execute(); /* @var $adapter Ruckusing_Adapter_MySQL_Base */ $adapter = $runner->get_adapter(); $runner->logger = null; $runner->initialize_logger(); $adapter->logger = $runner->logger; $adapter->drop_table($adapter->get_schema_version_table_name()); $this->assertFalse($adapter->table_exists($prefix . 'schema_migrations', true)); $this->assertFalse($adapter->table_exists($prefix . 'some_table', true)); }
protected function execute(InputInterface $input, OutputInterface $output) { $argv = $input->getArguments(); unset($argv['command']); $argv = array_values($argv); array_unshift($argv, './ruckus.php'); $_SERVER["argv"] = $argv; $dbConfig = $this->app->config('dbConfig'); $developmentConfig = array('type' => $dbConfig['type'], 'database' => $dbConfig['dbname'], 'host' => $dbConfig['host'], 'port' => $dbConfig['port'], 'user' => $dbConfig['user'], 'password' => $dbConfig['password'], 'charset' => $dbConfig['charset']); if (!empty($dbConfig['directory'])) { $developmentConfig['directory'] = $dbConfig['directory']; } $ruckusingConfig = array_merge(array('db' => array('development' => $developmentConfig)), $this->app->config('ruckusingConfig')); $main = new \Ruckusing_FrameworkRunner($ruckusingConfig, $argv); echo $main->execute(); }
<?php namespace w34u\ssp; require '../includeheader.php'; $cfg = \w34u\ssp\Configuration::getConfiguration(); if ($cfg->enableSetup !== true) { exit('Setup disabled, Enable in configuration, ->enableSetup'); } $content = []; if (!isset($_POST['SFC_Submit'])) { // set up database if not posting the form define('RUCKUSING_WORKING_BASE', getcwd()); $db_config = (require RUCKUSING_WORKING_BASE . DIRECTORY_SEPARATOR . 'ruckusing.conf.php'); if (isset($db_config['ruckusing_base'])) { define('RUCKUSING_BASE', $db_config['ruckusing_base']); } else { define('RUCKUSING_BASE', dirname(__FILE__)); } require_once RUCKUSING_BASE . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.inc.php'; $params = ['index.php', 'db:migrate']; $main = new \Ruckusing_FrameworkRunner($db_config, $params); $content['database_creation'] = $main->execute(); } $session = new Protect(); $ssp = new Setup($session, true); $admin = new UserAdmin($session, $ssp, '', 'sspsmalltemplate.tpl'); echo $admin->adminCreate($content);
<?php define('RUCKUSING_BASE', dirname(__FILE__)); date_default_timezone_set('America/New_York'); //requirements require RUCKUSING_BASE . '/lib/classes/util/class.Ruckusing_Logger.php'; require RUCKUSING_BASE . '/config/database.inc.php'; require RUCKUSING_BASE . '/lib/classes/class.Ruckusing_FrameworkRunner.php'; // global $main = new Ruckusing_FrameworkRunner($ruckusing_db_config, $argv); $main->execute(); // institute
require_once $file; break; } } if (class_exists('Composer\\Autoload\\ClassLoader', false)) { $composer_found = true; } } define('RUCKUSING_WORKING_BASE', getcwd()); $db_config = (require RUCKUSING_WORKING_BASE . DIRECTORY_SEPARATOR . 'ruckusing.conf.php'); if (isset($db_config['ruckusing_base'])) { define('RUCKUSING_BASE', $db_config['ruckusing_base']); } else { define('RUCKUSING_BASE', dirname(__FILE__)); } require_once RUCKUSING_BASE . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.inc.php'; if (!$composer_found) { set_include_path(implode(PATH_SEPARATOR, array(RUCKUSING_BASE . DIRECTORY_SEPARATOR . 'lib', get_include_path()))); function loader($classname) { include RUCKUSING_BASE . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $classname) . '.php'; } if ($php53) { spl_autoload_register('loader', true, true); } else { spl_autoload_register('loader', true); } } $main = new Ruckusing_FrameworkRunner($db_config, $argv); echo $main->execute();
/** * @param array $argv * @return Ruckusing_Adapter_Interface */ protected function migrateDatabase($argv) { $this->defineConstants(); $runnerReflection = new ReflectionClass('Ruckusing_FrameworkRunner'); defined('RUCKUSING_SCHEMA_TBL_NAME') or define('RUCKUSING_SCHEMA_TBL_NAME', WPT_DB_PREFIX . 'schema_info'); defined('RUCKUSING_TS_SCHEMA_TBL_NAME') or define('RUCKUSING_TS_SCHEMA_TBL_NAME', WPT_DB_PREFIX . 'schema_migrations'); defined('RUCKUSING_WORKING_BASE') or define('RUCKUSING_WORKING_BASE', dirname(dirname(__FILE__))); defined('RUCKUSING_BASE') or define('RUCKUSING_BASE', dirname(dirname(dirname($runnerReflection->getFileName())))); $databaseDirectory = RUCKUSING_WORKING_BASE . DIRECTORY_SEPARATOR . 'db'; $config = array('db' => array('development' => array('type' => DB_TYPE, 'host' => reset(explode(':', $this->wp->getDbHost())), 'port' => next(explode(':', $this->wp->getDbHost() . ':3306')), 'database' => $this->wp->getDbName(), 'directory' => 'wp_testing', 'user' => $this->wp->getDbUser(), 'password' => $this->wp->getDbPassword(), 'charset' => $this->wp->getDbCharset())), 'db_dir' => $databaseDirectory, 'migrations_dir' => array('default' => $databaseDirectory . DIRECTORY_SEPARATOR . 'migrations'), 'log_dir' => $this->wp->getTempDir() . 'wp_testing_' . md5(__FILE__)); $runner = new Ruckusing_FrameworkRunner($config, $argv); restore_error_handler(); restore_exception_handler(); $runner->execute(); /* @var $adapter Ruckusing_Adapter_Interface */ $adapter = $runner->get_adapter(); $adapter->logger = new Ruckusing_Util_Logger($config['log_dir'] . DIRECTORY_SEPARATOR . 'development.log'); return $adapter; }