/** * validate the table declaration */ private static function validate_table($tableDef = array()) { $valid = true; if ($tableDef) { if (!in_array($tableDef['type'], array('create', 'alter'))) { $valid = false; throw new Exception("Invalid Migration Type"); } if (!array_key_exists("table", $tableDef)) { $valid = false; throw new Exception("Table defination Missing."); } else { if (!array_key_exists("name", $tableDef['table'])) { $valid = false; throw new Exception("Table name missing."); } } if (!array_key_exists("columns", $tableDef)) { $valid = false; throw new Exception("Column defination Missing."); } else { $valid = uimodel::validate_cols($tableDef['columns']); } } else { $valid = false; throw new Exception("Table defination missing."); } return $valid; }
/** * Invokes the method to migrate the file to DB **/ private function run() { $tableDefination = array("type" => $this->migration_type, "table" => $this->table(), "columns" => $this->columns()); try { uimodel::migrate($tableDefination); } catch (Exception $e) { echo $e->getMessage(); } }