Skip to content

Feature request: Natively run Typescript migrations and seeders #693

Open
@mgibson91

Description

@mgibson91

In the same way that current CLI works, it would be great to be able to consume Typescript files.

My current project heavily uses aliases paths in development, runtime and testing using:

  • Dev: tsconfig paths
  • Test: Jest moduleNameMapper
  • Production: tsnode and tsconfigpaths

It's extremely pleasant.The amount of different solutions there are (which can also be a nightmare to get configured in all three execution contexts) give an indication to the importance and popularity of aliased paths.

Currently, to reuse existing code, I write my migrations, seeders and models all in Typescript, then transpile the migrations and seeders to JS so the sequelize cli can work its magic.

However, the pain comes when the transpiles JS has not converted the aliased paths to relative paths and understandably, the Sequelize migrator cannot find these aliased paths.

It would be so good to be able to natively run the Typescript migrations and seeders, perhaps via ts-node and tsconfig-paths so that a user can reuse code in the same way the do in the rest of their project with no extra work.

I expect it would require the migration code to be converted to Typescript and then be executed as:

ts-node -r tsconfig-paths/register migrator.ts
OR
node --require ts-node/register -r tsconfig-paths/register migrator.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions