inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

Slack 클론 코딩[백엔드 with NestJS + TypeORM]

typeorm seeding, migration

명령어로 sync 실행이 안됩니다 ㅜㅜ

423

찜닭

작성한 질문수 5

0

강좌에 나오는 schema:sync를 입력했는데

Synchronizes your entities with database schema. It runs schema update queries

on all connections you have. To run update queries on a concrete connection use

-c option.

옵션:

  -h, --help        도움말 표시                                         [불리언]

  -d, --dataSource  Path to the file where your DataSource instance is defined.

                                                                          [필수]

  -v, --version     버전 표시                                           [불리언]

필수 인수가 주어지지 않았습니다: dataSource

이러한 문구가 계속 나옵니다.

명령어로 sync를 하고싶은데 도와주세요 ㅠㅠ 구글링해도 나오질 않네요

 

제가 작성한 module은 다음과 같습니다.

import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { Users } from './entities/Users';

@Module({
  imports: [
    ConfigModule.forRoot({ isGlobal: true }),
    TypeOrmModule.forRootAsync({
      inject: [ConfigService],
      useFactory: async (configService: ConfigService) => {
        return {
          type: 'mysql',
          host:
            configService.get('TEST') === 'true'
              ? configService.get('TEST_HOST')
              : configService.get('HOST'),
          port:
            configService.get('TEST') === 'true'
              ? configService.get('TEST_DB_PORT')
              : configService.get('DB_PORT'),
          username:
            configService.get('TEST') === 'true'
              ? configService.get('TEST_USER_NAME')
              : configService.get('USER_NAME'),
          password:
            configService.get('TEST') === 'true'
              ? configService.get('TEST_PASSWORD')
              : configService.get('PASSWORD'),
          database:
            configService.get('TEST') === 'true'
              ? configService.get('TEST_DATABASE')
              : configService.get('DATABASE'),
          entities: [Users],
          migrations: [__dirname + '/src/migarions/*.ts'],

          cli: { migrationsDir: 'src/migrations' },
          charset: 'utf8mb4',
          synchronize: false,
          autoLoadEntities: true,
          keepConnectionAlive: true,
          logging: true,
        };
      },
    }),
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

 

nodejs express TypeORM NestJS

답변 1

0

제로초(조현영)

npm i typeorm@2 하셔서 2버전을 설치하세요. 3버전이 설치된 것 같습니다.

0

찜닭

0.3 공지에 나와있었군요

한번 적용해 보겠습니다!

0

찜닭

깃허브 이슈보고 해결했습니다.
감사합니다!

강의자료는 어디서 다운받나요?

0

145

4

질문 있습니다.

0

319

3

코드 편집기 확장 프로그램

0

220

2

(질문)비밀 저장소에 접근하기 위한 인증 정보는 로컬 .env에 저장하는지?

0

165

2

(질문)외부 저장소를 통한 환경변수 불러오기 비동기 질문

0

179

3

로그인을 해도 LoggedInGuard쪽에서 false값이 나옵니다.

0

163

2

로그인방법이 고민됩니다.

0

197

2

yarn seed 명령어 실행 시 데이터 삽입 안됨

0

305

4

yarn run db:create 시에 발생하는 데코레이터 오류

0

249

2

npm run db:create 시에 발생하는 decorating 오류

0

245

2

RxJS 디버깅 질문 있습니다.

0

200

3

CacheManager에 대해 질문 있습니다.

0

185

2

로깅은 어떻게 하는게 효율적일까요?

0

240

1

CORS 질문 있습니다.

0

428

2

쿠키 옵션에 대해서 질문 있습니다.

0

190

2

로그아웃 요청이 403 forbidden 에러가 나는데 왜그런걸까요??

0

458

1

401 unauthorized문제

0

306

1

가드의 장점에 대해서 질문이 있습니다.

0

234

1

로그 관리에 대해 질문 있습니다.

0

256

2

CORS 에러 질문 있습니다.

0

329

2

배포 환경 DB 연결 질문 있습니다.

0

417

2

socket io 미 연결 문제 (nest & flutter)

1

1169

3

no elements in sequence 에러 관해서 질문이 있습니다.

0

465

1

start:dev-backup으로 돌리면 핫 리로딩이 되요 정상인가요?

0

327

1