Directus Migration Tools (v1.0.75) is a utility library for generating Directus migration files programmatically. It provides helper functions to define collections, fields, and special field types (e.g., translations, files, WYSIWYG) as JavaScript objects, then compiles them into up/down migration functions compatible with Directus's migration system. The package simplifies creating repeatable, version-controlled schema migrations without manual SQL. It is actively maintained and updated by codihaus, with frequent releases on a weekly cadence. Key differentiators include its compositional API (generateField, generateSpecField), built-in support for Directus special fields (M2O, M2M, translations, sorting), and a test suite. It is designed for Directus v9+ and requires Node.js and knex.
npm install directus-migration-toolsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a migration file defining a collection with fields, using upCreateKnex/downCreateKnex to apply/revert schema changes.
Use require() instead of import when consuming this package.
For UUID primary keys: generateField.genPrimaryKey('uuid'); for string keys: generateField.genPrimaryKey('string').Replace genDatetime('date-created') with generateSpecField.dateCreated({}).Ensure the migration file is saved under extensions/migrations/ with correct naming: [identity]-name.js.
Run 'npm install directus-migration-tools' and ensure const { upCreateKnex } = require('directus-migration-tools'); is used.Install the package: npm install directus-migration-tools.
Add const { generateField } = require('directus-migration-tools'); at the top of the migration file.Remove the duplicate entry or rename one of the collections.
No dependency data recorded yet.