/** * 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(); }
protected function setUp() { global $ruckusing_db_config; if (!is_array($ruckusing_db_config) || !array_key_exists("test", $ruckusing_db_config)) { die("\n'test' DB is not defined in config/database.inc.php\n\n"); } $test_db = $ruckusing_db_config['test']; //setup our log $logger = Ruckusing_Logger::instance(RUCKUSING_BASE . '/tests/logs/test.log'); $this->adapter = new Ruckusing_MySQLAdapter($test_db, $logger); $this->adapter->logger->log("Test run started: " . date('Y-m-d g:ia T')); //create the schema table if necessary $this->adapter->create_schema_version_table(); $framework = new Ruckusing_FrameworkRunner($ruckusing_db_config, null); $this->migrations_dir = $framework->migrations_directory(); if (!is_dir($this->migrations_dir)) { mkdir($this->migrations_dir); } }
/** * Setup commands before test case */ protected function setUp() { $ruckusing_config = (require RUCKUSING_BASE . '/config/database.inc.php'); if (!is_array($ruckusing_config) || !(array_key_exists("db", $ruckusing_config) && array_key_exists("mysql_test", $ruckusing_config['db']))) { $this->markTestSkipped("\n'mysql_test' DB is not defined in config/database.inc.php\n\n"); } $test_db = $ruckusing_config['db']['mysql_test']; //setup our log $logger = Ruckusing_Util_Logger::instance(RUCKUSING_BASE . '/tests/logs/test.log'); $this->adapter = new Ruckusing_Adapter_MySQL_Base($test_db, $logger); $this->adapter->logger->log("Test run started: " . date('Y-m-d g:ia T')); //create the schema table if necessary $this->adapter->create_schema_version_table(); $framework = new Ruckusing_FrameworkRunner($ruckusing_config, array('ENV=mysql_test')); $this->migrations_dir = $framework->migrations_directory(); if (!is_dir($this->migrations_dir)) { mkdir($this->migrations_dir, 0755, true); } }
/** * Setup commands before test case */ protected function setUp() { $ruckusing_config = (require RUCKUSING_BASE . '/config/database.inc.php'); if (!is_array($ruckusing_config) || !(array_key_exists("db", $ruckusing_config) && array_key_exists("mysql_test", $ruckusing_config['db']))) { $this->markTestSkipped("\n'mysql_test' DB is not defined in config/database.inc.php\n\n"); } $test_db = $ruckusing_config['db']['mysql_test']; //setup our log $logger = Ruckusing_Util_Logger::instance(RUCKUSING_BASE . '/tests/logs/test.log'); $this->adapter = new Ruckusing_Adapter_MySQL_Base($test_db, $logger); $this->adapter->logger->log("Test run started: " . date('Y-m-d g:ia T')); //create the schema table if necessary $this->adapter->create_schema_version_table(); $framework = new Ruckusing_FrameworkRunner($ruckusing_config, array('ENV=mysql_test')); $this->migrations_dirs = $framework->migrations_directories(); // additional path addede here - because of non-changing main config file for useless dir $this->migrations_dirs['additional'] = RUCKUSING_WORKING_BASE . '/migrations/second_test_dir'; // need to deal with array, not just string at main foreach ($this->migrations_dirs as $key => $dir) { if (!is_dir($dir)) { mkdir($dir, 0755, true); } } }
<?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
if (file_exists($file)) { 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();
<?php /* The table for keeping track of Ruckusing Migrations has changed so we need to alter the schema and migrate over existing migrations. */ define('RUCKUSING_BASE', dirname(__FILE__)); //requirements require RUCKUSING_BASE . '/lib/classes/util/class.Ruckusing_Logger.php'; require RUCKUSING_BASE . '/config/config.inc.php'; require RUCKUSING_BASE . '/config/database.inc.php'; require RUCKUSING_BASE . '/lib/classes/class.Ruckusing_FrameworkRunner.php'; echo "\n\nStarting upgrade process.\n"; $main = new Ruckusing_FrameworkRunner($ruckusing_db_config, $argv); $main->update_schema_for_timestamps(); echo "\n\nSuccesfully completed uprade!\n"; $notice = <<<NOTICE Ruckusing Migrations now uses the table '%s' to keep track of migrations. The old table '%s' can be removed at your leisure. NOTICE; printf("\n{$notice}\n\n", RUCKUSING_TS_SCHEMA_TBL_NAME, RUCKUSING_SCHEMA_TBL_NAME);
/** * @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; }
<?php /* Generator for migrations. Usage: php generate.php <migration name> Call with no arguments to see usage info. */ define('RUCKUSING_BASE', realpath(dirname(__FILE__))); require RUCKUSING_BASE . '/config/config.inc.php'; require RUCKUSING_BASE . '/config/database.inc.php'; require RUCKUSING_BASE . '/lib/classes/util/class.Ruckusing_Logger.php'; require RUCKUSING_BASE . '/lib/classes/util/class.Ruckusing_NamingUtil.php'; require RUCKUSING_BASE . '/lib/classes/util/class.Ruckusing_MigratorUtil.php'; require RUCKUSING_BASE . '/lib/classes/class.Ruckusing_FrameworkRunner.php'; $args = parse_args($argv); $framework = new Ruckusing_FrameworkRunner($ruckusing_db_config, null); //input sanity check if (!is_array($args) || is_array($args) && !array_key_exists('name', $args)) { print_help(true); } $migration_name = $args['name']; //clear any filesystem stats cache clearstatcache(); //generate a complete migration file $next_version = Ruckusing_MigratorUtil::generate_timestamp(); $klass = Ruckusing_NamingUtil::camelcase($migration_name); $file_name = $next_version . '_' . $klass . '.php'; $migrations_dir = $framework->migrations_directory(); $template_str = get_template($klass); if (!is_dir($migrations_dir)) { printf("\n\tMigrations directory (%s doesn't exist, attempting to create.", $migrations_dir);