인프런 커뮤니티 질문&답변

진승이님의 프로필 이미지
진승이

작성한 질문수

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

dataSource

작성

·

381

·

수정됨

0

                   AND
                    `TABLE_NAME` = 'channels'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                WHERE
                    `CONSTRAINT_SCHEMA` = 'sleact'
                    AND
                    `TABLE_NAME` = 'channelchats'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                WHERE
                    `CONSTRAINT_SCHEMA` = 'sleact'
                    AND
                    `TABLE_NAME` = 'users'
            ) `rc`
                ON
                    `rc`.`CONSTRAINT_SCHEMA` = `kcu`.`CONSTRAINT_SCHEMA`
                    AND
                    `rc`.`TABLE_NAME` = `kcu`.`TABLE_NAME`
                    AND
                    `rc`.`CONSTRAINT_NAME` = `kcu`.`CONSTRAINT_NAME`
            
query: SELECT VERSION() AS `version`
query: SELECT * FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA` = 'sleact' AND `TABLE_NAME` = 'typeorm_metadata'
query: DROP INDEX `UserId` ON `workspacemembers`
query failed: DROP INDEX `UserId` ON `workspacemembers`
error: Error: Cannot drop index 'UserId': needed in a foreign key constraint
query: ROLLBACK
[Nest] 81848  - 2023. 09. 20. 오전 12:47:04   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (9)...
QueryFailedError: Cannot drop index 'UserId': needed in a foreign key constraint
    at Query.onResult (/Users/yujinseung/Desktop/Slack/slack_s/src/driver/mysql/MysqlQueryRunner.ts:222:33)
    at Query.execute (/Users/yujinseung/Desktop/Slack/slack_s/node_modules/mysql2/lib/commands/command.js:36:14)
    at PoolConnection.handlePacket (/Users/yujinseung/Desktop/Slack/slack_s/node_modules/mysql2/lib/connection.js:478:34)
    at PacketParser.onPacket (/Users/yujinseung/Desktop/Slack/slack_s/node_modules/mysql2/lib/connection.js:97:12)
    at PacketParser.executeStart (/Users/yujinseung/Desktop/Slack/slack_s/node_modules/mysql2/lib/packet_parser.js:75:16)
    at Socket.<anonymous> (/Users/yujinseung/Desktop/Slack/slack_s/node_modules/mysql2/lib/connection.js:104:25)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Socket.Readable.push (node:internal/streams/readable:234:10)
[Nest] 81848  - 2023. 09. 20. 오전 12:47:04   ERROR [ExceptionHandler] Cannot drop index 'UserId': needed in a foreign key constraint
QueryFailedError: Cannot drop index 'UserId': needed in a foreign key constraint
    at Query.onResult (/Users/yujinseung/Desktop/Slack/slack_s/src/driver/mysql/MysqlQueryRunner.ts:222:33)
    at Query.execute (/Users/yujinseung/Desktop/Slack/slack_s/node_modules/mysql2/lib/commands/command.js:36:14)
    at PoolConnection.handlePacket (/Users/yujinseung/Desktop/Slack/slack_s/node_modules/mysql2/lib/connection.js:478:34)
    at PacketParser.onPacket (/Users/yujinseung/Desktop/Slack/slack_s/node_modules/mysql2/lib/connection.js:97:12)
    at PacketParser.executeStart (/Users/yujinseung/Desktop/Slack/slack_s/node_modules/mysql2/lib/packet_parser.js:75:16)
    at Socket.<anonymous> (/Users/yujinseung/Desktop/Slack/slack_s/node_modules/mysql2/lib/connection.js:104:25)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Socket.Readable.push (node:internal/streams/readable:234:10)

이런오류가 뜹니다..! 뭐가 문제인지 모르겠습니당..

https://github.com/jinseung0327/slack_clone

혹시나 해서 깃허브 주소까지 올립니닷..!

답변 2

0

제로초(조현영)님의 프로필 이미지
제로초(조현영)
지식공유자

TypeOrmModule 세팅 하셨나요?

진승이님의 프로필 이미지
진승이
질문자

appmodule.ts에 안한게있어서 넣고 했는데 위에 수정한 저 오류가 뜹니다..!

진승이님의 프로필 이미지
진승이
질문자

깃허브한번 봐주시면 감사하겠습니다..!

제로초(조현영)님의 프로필 이미지
제로초(조현영)
지식공유자

TypeOrmModule 옵션 중에 synchronize: true 넣고 다시 실행해보세요.

진승이님의 프로필 이미지
진승이
질문자

true로 해도 똑같이 뜹니닷..!

 

제로초(조현영)님의 프로필 이미지
제로초(조현영)
지식공유자

결론은 디비 테이블 싹 지우고 다시 만드시면 됩니다.

제로초(조현영)님의 프로필 이미지
제로초(조현영)
지식공유자

에러메시지 읽어보세요. 저 경로에 저 파일이 없는 겁니다.

진승이님의 프로필 이미지
진승이
질문자

회원가입창에서 다입력하고 회원가입버튼을 눌러도 아무일이 안일어나고

혹시나 회원가입이 된건가해서 로그인창에 그대로 다 입력해도 아무일이 안 일어납니다..!

https://github.com/jinseung0327/Slack_

제로초(조현영)님의 프로필 이미지
제로초(조현영)
지식공유자

일단 깃헙만 올리시는 건 저는 아예 안 봅니다(질문 공지사항 참조하세요). 아무 일이 안 일어나면 왜 안 일어나는지 콘솔로그도 찍어보시고, 네트워크 탭에서 요청/응답 제대로 주고받고 있는지 확인도 해보시고 그 결과를 저한테 보여주세요.

0

사진말고 복사 붙여넣기 해서 올리시면 안되나요? 확대도 안돼서 확인하기가 힘듭니다.

진승이님의 프로필 이미지
진승이
질문자

아 넵..!!

 

[Nest] 44738  - 2023. 09. 19. 오후 11:38:53   ERROR [ExceptionHandler] Nest can't resolve dependencies of the UsersRepository (?). Please make sure that the argument DataSource at index [0] is available in the TypeOrmModule context.

Potential solutions:
- Is TypeOrmModule a valid NestJS module?
- If DataSource is a provider, is it part of the current TypeOrmModule?
- If DataSource is exported from a separate @Module, is that module imported within TypeOrmModule?
  @Module({
    imports: [ /* the Module containing DataSource */ ]
  })

Error: Nest can't resolve dependencies of the UsersRepository (?). Please make sure that the argument DataSource at index [0] is available in the TypeOrmModule context.

Potential solutions:
- Is TypeOrmModule a valid NestJS module?
- If DataSource is a provider, is it part of the current TypeOrmModule?
- If DataSource is exported from a separate @Module, is that module imported within TypeOrmModule?
  @Module({
    imports: [ /* the Module containing DataSource */ ]
  })

    at Injector.lookupComponentInParentModules (/Users/yujinseung/Desktop/Slack/slack_s/node_modules/@nestjs/core/injector/injector.js:254:19)
    at Injector.resolveComponentInstance (/Users/yujinseung/Desktop/Slack/slack_s/node_modules/@nestjs/core/injector/injector.js:207:33)
    at resolveParam (/Users/yujinseung/Desktop/Slack/slack_s/node_modules/@nestjs/core/injector/injector.js:128:38)
    at async Promise.all (index 0)
    at Injector.resolveConstructorParams (/Users/yujinseung/Desktop/Slack/slack_s/node_modules/@nestjs/core/injector/injector.js:143:27)
    at Injector.loadInstance (/Users/yujinseung/Desktop/Slack/slack_s/node_modules/@nestjs/core/injector/injector.js:70:13)
    at Injector.loadProvider (/Users/yujinseung/Desktop/Slack/slack_s/node_modules/@nestjs/core/injector/injector.js:97:9)
    at /Users/yujinseung/Desktop/Slack/slack_s/node_modules/@nestjs/core/injector/instance-loader.js:56:13
    at async Promise.all (index 3)
    at InstanceLoader.createInstancesOfProviders (/Users/yujinseung/Desktop/Slack/slack_s/node_modules/@nestjs/core/injector/instance-loader.js:55:9)

진승이님의 프로필 이미지
진승이
질문자

npm run seed는 됩니닷..!

진승이님의 프로필 이미지
진승이

작성한 질문수

질문하기