Skip to content

@vttforge/core / createMigrationRunner

Function: createMigrationRunner()

createMigrationRunner(options): MigrationRunner

Build a migration runner for a system. See module header for the failure semantics; see Migration JSDoc for the per-entry shape.

Parameters

options

MigrationRunnerOptions

Returns

MigrationRunner

Example

ts
const migrations = createMigrationRunner({
  systemId: 'my-system',
  migrations: [
    { version: '1.0.0', description: 'Rename bio → biography', fn: migrateV1 },
    { version: '2.0.0', description: 'Add hp.temp', fn: migrateV2 },
  ],
  compatibleVersion: '0.9.0',
});

registerSystem({
  id: 'my-system',
  onAfterInit: () => migrations.register(),
  onReady: async () => {
    if (!game.user.isGM) return;
    await migrations.run();
  },
});

MIT licensed.