You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the capacitor driver and a typescript datasource, I can not successfully run migration:generate
Expected Behavior
Create a migration file
Actual Behavior
% npx typeorm-ts-node-commonjs migration:generate -d src/app/data-sources/AuthorDataSource.ts foo
Error during migration generation:
Error: Unable to open file: "/Users/philip/Cloud/workspace/ionic-sqlite-typeorm-app/src/app/data-sources/AuthorDataSource.ts". Cannot use import statement outside a module
at Function.loadDataSource (/Users/philip/Cloud/workspace/ionic-sqlite-typeorm-app/node_modules/src/commands/CommandUtils.ts:22:19)
at async Object.handler (/Users/philip/Cloud/workspace/ionic-sqlite-typeorm-app/node_modules/src/commands/MigrationGenerateCommand.ts:78:26)
philip@MacBook-Pro ~/workspace/ionic-sqlite-typeorm-app
% npx typeorm-ts-node-esm migration:generate -d src/app/data-sources/AuthorDataSource.ts foo
Error during migration generation:
Error: Unable to open file: "/Users/philip/Cloud/workspace/ionic-sqlite-typeorm-app/src/app/data-sources/AuthorDataSource.ts". Cannot use import statement outside a module
at Function.loadDataSource (/Users/philip/Cloud/workspace/ionic-sqlite-typeorm-app/node_modules/src/commands/CommandUtils.ts:22:19)
at async Object.handler (/Users/philip/Cloud/workspace/ionic-sqlite-typeorm-app/node_modules/src/commands/MigrationGenerateCommand.ts:78:26)
I am experiencing the same problem with the default postgres driver. So, I don't think this kind of error is tied to driver stuff.
However, there are two workarounds known to me:
use npx ts-node -r tsconfig-paths/register node_modules/typeorm/cli -d <path/to/datasource> path/to/migrations/<migration-name> to generate a migration file based on changes to TypeScript entities
use npx typeorm-ts-node-commonjs migration:generate -d <path/to/datasource> path/to/migrations/<migration-name>
With this option, it is necessary to specify path to the JavaScript entities from the dist directory
(e.g. entities: [path.resolve('dist', '**', '*.entity.js')])
Issue description
When using the capacitor driver and a typescript datasource, I can not successfully run migration:generate
Expected Behavior
Create a migration file
Actual Behavior
Steps to reproduce
Check out and set up https://github.com/jepiqueau/ionic-sqlite-typeorm-app then run
typeorm migration:generate -d src/app/data-sources/AuthorDataSource.ts foo
My Environment
Additional Context
No response
Relevant Database Driver(s)
Are you willing to resolve this issue by submitting a Pull Request?
Yes, I have the time, but I don't know how to start. I would need guidance.
The text was updated successfully, but these errors were encountered: