Esempio n. 1
0
 /**
  * Primary task entry point
  *
  * @param array $args The current supplied options.
  */
 public function execute($args)
 {
     $output = "Started: " . date('Y-m-d g:ia T') . "\n\n";
     $output .= "[db:version]: \n";
     if (!$this->_adapter->table_exists($this->_adapter->get_schema_version_table_name())) {
         //it doesnt exist, create it
         $output .= "\tSchema version table (" . $this->_adapter->get_schema_version_table_name() . ") does not exist. Do you need to run 'db:setup'?";
     } else {
         //it exists, read the version from it
         // We only want one row but we cannot assume that we are using MySQL and use a LIMIT statement
         // as it is not part of the SQL standard. Thus we have to select all rows and use PHP to return
         // the record we need
         $versions_nested = $this->_adapter->select_all(sprintf("SELECT version FROM %s", $this->_adapter->get_schema_version_table_name()));
         $versions = array();
         foreach ($versions_nested as $v) {
             $versions[] = $v['version'];
         }
         $num_versions = count($versions);
         if ($num_versions > 0) {
             sort($versions);
             //sorts lowest-to-highest (ascending)
             $version = (string) $versions[$num_versions - 1];
             $output .= sprintf("\tCurrent version: %s", $version);
         } else {
             $output .= sprintf("\tNo migrations have been executed.");
         }
     }
     $output .= "\n\nFinished: " . date('Y-m-d g:ia T') . "\n\n";
     return $output;
 }
 /**
  * Primary task entry point
  *
  * @param array $args The current supplied options.
  */
 public function execute($args)
 {
     $output = "Started: " . date('Y-m-d g:ia T') . "\n\n";
     $output .= "[db:setup]: \n";
     //it doesnt exist, create it
     if (!$this->_adapter->table_exists(RUCKUSING_TS_SCHEMA_TBL_NAME)) {
         $output .= sprintf("\tCreating table: %s", RUCKUSING_TS_SCHEMA_TBL_NAME);
         $this->_adapter->create_schema_version_table();
         $output .= "\n\tDone.\n";
     } else {
         $output .= sprintf("\tNOTICE: table '%s' already exists. Nothing to do.", RUCKUSING_TS_SCHEMA_TBL_NAME);
     }
     $output .= "\n\nFinished: " . date('Y-m-d g:ia T') . "\n\n";
     return $output;
 }
Esempio n. 3
0
 /**
  * Check the environment and create the migration dir if it doesn't exists
  */
 private function verify_environment()
 {
     if (!$this->_adapter->table_exists(RUCKUSING_TS_SCHEMA_TBL_NAME)) {
         $this->_return .= "\n\tSchema version table does not exist. Auto-creating.";
         $this->auto_create_schema_info_table();
     }
     $this->_migratorDirs = $this->get_framework()->migrations_directories();
     // create the migrations directory if it doesnt exist
     foreach ($this->_migratorDirs as $name => $path) {
         if (!is_dir($path)) {
             $this->_return .= sprintf("\n\tMigrations directory (%s) doesn't exist, attempting to create.", $path);
             if (mkdir($path, 0755, true) === FALSE) {
                 $this->_return .= sprintf("\n\tUnable to create migrations directory at %s, check permissions?", $path);
             } else {
                 $this->_return .= sprintf("\n\tCreated OK");
             }
         }
     }
 }
 /**
  * Check the environment and create the migration dir if it doesn't exists
  */
 private function verify_environment()
 {
     if (!$this->_adapter->table_exists(RUCKUSING_TS_SCHEMA_TBL_NAME)) {
         $this->_return .= "\n\tSchema version table does not exist. Auto-creating.";
         $this->auto_create_schema_info_table();
     }
     $this->_migratorDir = $this->get_framework()->migrations_directory();
     // create the migrations directory if it doesnt exist
     if (!is_dir($this->_migratorDir)) {
         $this->_return .= sprintf("\n\tMigrations directory (%s doesn't exist, attempting to create.", $this->_migratorDir);
         if (mkdir($this->_migratorDir, 0755, true) === FALSE) {
             $this->_return .= sprintf("\n\tUnable to create migrations directory at %s, check permissions?", $this->_migratorDir);
         } else {
             $this->_return .= sprintf("\n\tCreated OK");
         }
     }
     //check to make sure our destination directory is writable
     if (!is_writable($this->_migratorDir)) {
         throw new Ruckusing_Exception("ERROR: Migrations directory '" . $this->_migratorDir . "' is not writable by the current user. Check permissions and try again.\n", Ruckusing_Exception::INVALID_MIGRATION_DIR);
     }
 }