protected function copyModuleMigrations(array $config, array $moduleMigrations)
    {
        $migrationPath = $this->checkMigrationsPath($config);
        if ($migrationPath === false) {
            return false;
        }

        $migrations = glob($migrationPath . '*.php');
        $old_migration_names = array();
        $copied = 0;

        sort($migrations);
        foreach ($migrations as $migration) {
            $old_migration_names[] = $this->getMigrationName($migration);
        }

        if (isset($config['migration_type']) && $config['migration_type'] === 'timestamp') {
            $number = (int) date('YmdHis');
        } else {
            // Get the latest migration number and increment
            if (count($migrations) > 0) {
                $migration = array_pop($migrations);
                $number    = ((int) basename($migration)) + 1;
            } else {
                $number = 1;
            }
        }

        // Copy each migration into the application migration directory
        foreach ($moduleMigrations as $migration) {
            if (array_search($this->getMigrationName($migration), $old_migration_names) === false) {
                // Re-number the migration
                $newMigration = $migrationPath .
                preg_replace('/^(\d+)/', sprintf('%03d', $number), basename($migration));

                // Copy the migration file
                copy($migration, $newMigration);

                $number++;
                $copied++;
            }
        }

        return $copied;
    }