Make sure you have ts-node installed: npm install ts-node
This creates a .ts file in migrations directory
npm run knex:migrate:make -- some-migration-name
npm run knex:migrate:latest
npm run knex:migrate:rollback
knexfile.ts
requiresrequire('ts-node/register');
to work.- ES6/ES2015 module syntax does not work in knexfile or in any files that it
require()
s
If you still have the "-x" issue, explanation is simple, there's a mistake in the gist.
Instead of doing "knex -x ts migrate:make migration_name" you need to do "knex migrate:make -x ts migration_name".
My script works like this:
// package.json script:
"knex:migrate:make": "knex --knexfile src/knexfile.ts migrate:make -x ts",
// in terminal:
npm run knex:migrate:make migration_name