jiroch
jiroch

Reputation: 424

How to run migrations in a feathersjs typescript project?

I'm wondering how to run Sequelize migrations on a typescript feathersjs project generated by feathers-plus CLI.

The guide at https://github.com/feathersjs-ecosystem/feathers-sequelize is only concerned with JS project. TS project where sequelize migrations config created exactly according to the doc will fail with not being able to find the app module.

ERROR: Cannot find module '../src/app'

How to get it working? (I don't want to go all out Typescript on Sequelize with 3rd party typings as I smell it would bring a whole new league of issues)

Upvotes: 1

Views: 1663

Answers (2)

Joshua Opata
Joshua Opata

Reputation: 681

migrations/config.js

change const app = require('../src/app'); to const app = require('../lib/app');

after running npm run compile

you can now run npx sequelize db:migrate

Upvotes: 0

jiroch
jiroch

Reputation: 424

I found a very simple way to get it working. Just change the extensions on the migrations/config.js and migrations/models.js files to ts.

So you now have migrations/config.ts and migrations/models.ts and you can run migrations in the usual way using sequelize db:migrate

Voilá!

Upvotes: -1

Related Questions