I was recently trying to move from typeorm to mikroorm but I am unable to use the feature where entity will be automatically created, there are no errors but it is not reflected on db/schema/table,
Can anyone tell me what I am doing wrong.
You can see the structure of my app as shown in photo
- Here is My User Entity ( src/user/user.entity.ts)
import { Entity, PrimaryKey, Property } from '@mikro-orm/core';
@Entity()
export class User {
@PrimaryKey()
id: number;
@Property()
name: string;
}
- Here is my User Module where I imported the entity ( src/user/user.module.ts)
import { MikroOrmModule } from '@mikro-orm/nestjs';
import { Module } from '@nestjs/common';
import { User } from './user.entity';
@Module({
imports: [MikroOrmModule.forFeature([User])],
})
export class UserModule {}
- And here is my app.module.ts (src/app.module.ts)
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { UserModule } from './user/user.module';
import { ConfigModule } from '@nestjs/config';
import { MikroOrmModule } from '@mikro-orm/nestjs';
import { PostgreSqlDriver } from '@mikro-orm/postgresql';
import env from './env';
@Module({
imports: [
ConfigModule.forRoot(),
MikroOrmModule.forRoot({
dbName: 'mikro-orm-testing',
driver: PostgreSqlDriver,
clientUrl: env.DATABASE_URL,
autoLoadEntities: true,
ensureDatabase: true,
}),
UserModule,
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}