nest icon indicating copy to clipboard operation
nest copied to clipboard

TypeORM migrations

Open vlio20 opened this issue 9 years ago • 7 comments

Hi, Is there a way to run migrations with defining the connection as described in the docs?

export const databaseProviders = [
  {
    provide: DB_CON_TOKEN,
    useFactory: async () => await createConnection({
      type: 'mysql',
      host: 'localhost',
      port: 3306,
      username: 'root',
      password: 'root',
      database: 'test',
      entities: [
        __dirname + '/../**/*.entity{.ts,.js}',
      ],
      migrations: [
        __dirname + '/migrations/*.migration{.ts,.js}'
      ]
    }),
  },
]; 

The only option I see is to configure 2 dbConnections, one for nest (for the repository/entity) and one for TypeORM for the migrations.

vlio20 avatar Oct 24 '17 20:10 vlio20

Doesn't really have anything to do with Nest. What exists in the docs is just a simple example of how you could add TypeORM to a Nest server, it's far from the only way to do so.

There is a slightly more robust example here - https://github.com/zachgrayio/nest-typeorm-example

Note the database module used in conjunction with feature module specific TypeORM configs.

joshwiens avatar Oct 24 '17 20:10 joshwiens

awesome! thanks for providing the example

vlio20 avatar Oct 24 '17 21:10 vlio20

I'm using TypeORM / Nest in prod @ work. You can find me in gitter under the same name if you continue to have trouble with it.

joshwiens avatar Oct 24 '17 21:10 joshwiens

thanks @d3viant0ne ... I will :)

vlio20 avatar Oct 24 '17 21:10 vlio20

Example repo https://github.com/zachgrayio/nest-typeorm-example is 404ing right now.

mattwelke avatar Nov 17 '17 03:11 mattwelke

@welkie https://github.com/kamilmysliwiec/nest-typeorm-example

jgordor avatar Nov 17 '17 06:11 jgordor

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Sep 25 '19 09:09 lock[bot]