public function handleMigration($p) { Zinc::loadLib('migration'); Zinc::loadLib('utils'); if ($p[2] == 'migration') { $type = 'migration'; } else { if ($p[2] == 'seed') { $type = 'seed'; } else { trigger_error("invalid migration type: " . $p[2]); } } $max = Migration::getMaxMigration($type); $version = $max + 1; $moduleName = false; if ($p[count($p) - 2] == 'from') { $moduleName = $p[count($p) - 1]; $name = 'init' . ucfirst($moduleName); } else { $name = $p[3]; } $stationaryFilename = 'migration.tpl'; if ($moduleName) { $stationaryFilename = Zinc::getModDir($moduleName) . "/stationary/{$stationaryFilename}"; } else { $stationaryFilename = app_dir . "/stationary/{$stationaryFilename}"; } if (!file_exists($stationaryFilename)) { echo "stationary file at {$stationaryFilename} does not exist\n"; return; } $versionString = str_pad($version, 4, "0", STR_PAD_LEFT); $params = array(); // $params['version'] = str_replace('.', '_', $versionString); $params['version'] = $versionString; $params['type'] = $type; if ($type == 'migration') { $dir = app_dir . '/migrations'; } else { if (!($subdir = Config::get('zinc.migrations.seedName'))) { trigger_error("configuration for seed subdirectory is missing"); } $dir = app_dir . '/seeds/' . $subdir; } $newFilename = $dir . '/' . $versionString . '_' . $name . '.php'; self::gen($stationaryFilename, $newFilename, $params); }