コード例 #1
0
ファイル: installer.php プロジェクト: juaniiie/mwi
 public static function migrate($module_slug, $action = 'run')
 {
     require path('sys') . 'cli' . DS . 'dependencies' . EXT;
     try {
         $migrations_path = path('bundle') . $module_slug . DS . 'migrations' . DS;
         if (File::exists($migrations_path)) {
             $migration_files = glob($migrations_path . '*.php');
             if (!empty($migration_files)) {
                 if ($action == 'run') {
                     Bundle::register($module_slug);
                     $custom_tables = \Laravel\CLI\Command::run(array('migrate', $module_slug));
                     Bundle::disable($module_slug);
                     return true;
                 }
                 if ($action == 'rollback') {
                     Bundle::register($module_slug);
                     $custom_tables = \Laravel\CLI\Command::run(array('migrate:rollback', $module_slug));
                     Bundle::disable($module_slug);
                     return true;
                 }
                 Log::error('Failed to run migrations for module ' . $module_slug . '. Migration command [' . $action . '] is invalid.');
                 static::$errors->add('installer', 'Failed to run migrations for module ' . $module_slug . '. Migration command [' . $action . '] is invalid.');
                 return false;
             }
         }
         return true;
     } catch (\Exception $e) {
         Log::error($e->getMessage());
         //static::$errors->add('installer', 'Failed to run migrations.');
         return false;
     }
 }