Launch a 'alanning:roles' package command

Hi, I am migrating the ‘alanning:roles’ package from v1 to v3, and I want to do this from a migrations file with “meteor/percolate:migrations” package.

In the ‘alaning:roles’ documentation, to migrate to v2, I need to launch this:

meteor shell
> Package['alanning:roles'].Roles._forwardMigrate()

My question is, is there a way to launch this shell or the package command from a migration file?

Thanks!

Have you tried calling Roles._forwardMigrate() from the up hook of the Migrations.add?

Hi, thanks for the response.

Yes, I’ve installed the @types/meteor-roles package and created a TS file with the hook Migrations.add but I get Property '_forwardMigrate' does not exist on type 'typeof Roles'. error in the IDE.

import { Migrations } from "meteor/percolate:migrations";
import { Roles } from "meteor/alanning:roles";

Migrations.add({
  version: 41,
  name: "Migrate alaning roles to v3.",
  up() {
    Roles._forwardMigrate();
  },
  down() {},
});

Types are already part of the package, no need to install the @types one. But still we don’t have that function in the definition.
Feel free to submit a PR or raise an issue on the repository.

1 Like

meteor shell

Package[‘alanning:roles’].Roles._forwardMigrate2()

Just looked at the docs and it seems that you need to call _forwardMigrate2() to migrate from 2 to 3

2 Likes

Oh, ok, thanks for the response!

Yes, but the point here is to don’t do this from the meteor shell. Thanks for your time!