kookmin-sw / capstone-2023-05

capstone-2023-05 created by GitHub Classroom
https://capstone-2023-05.vercel.app
0 stars 0 forks source link

Feat: Adapt data model (PostgreSQL) #30

Closed Binsk-dev closed 1 year ago

Binsk-dev commented 1 year ago

backend/model.sql을 만들어 두었습니다. 이를 이용하기 위해서는 다음과 같은 작업을 합니다.

  1. docker compose를 이용해 2개의 컨테이너를 띄운다. 환경변수에 적어놓았던 값들 기억해두어야 함!(성공시 redis, db 라는 이름의 컨테이너가 running 된다.)
  2. docker cp [model_file_path] db:/model.sql를 적용해 DDL 파일을 컨테이너 안으로 복사한다.
  3. docker exec 를 이용해 아래의 명령어를 실행
  4. 환경변수 정보들을 기반으로 psql -h localhost -f model.sql [DB이름] -U [DB유저이름] 실행
  5. sql문으로 작동확인
Jaewook-Lee commented 1 year ago

환경 변수 POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB 값은 제가 새로 postgres 계정 같은걸 만들어서 얻어야 하나요?

ChangHoon-Sung commented 1 year ago

임의로 지정하면 됩니다 On Mar 16, 2023 14:04 +0900, Jaewook-Lee @.***>, wrote:

환경 변수 POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB 값은 제가 새로 postgres 계정 같은걸 만들어서 얻어야 하나요? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because your review was requested.Message ID: @.***>

Jaewook-Lee commented 1 year ago

docker-compose up 이 sudo 권한을 요구해서 sudo docker-compose up을 실행하니 아래와 같은 에러를 얻었습니다.

db       | Error: Database is uninitialized and superuser password is not specified.
db       |        You must specify POSTGRES_PASSWORD to a non-empty value for the
db       |        superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run".
db       | 
db       |        You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all
db       |        connections without a password. This is *not* recommended.
db       | 
db       |        See PostgreSQL documentation about "trust":
db       |        https://www.postgresql.org/docs/current/auth-trust.html

.envrc에서 환경 변수 값들을 다 1234로 설정했는데 super user에 대해서도 따로 설정해야 하나요?

ChangHoon-Sung commented 1 year ago

docker가 sudo 권한을 요구하는 경우 별도로 sudo로 실행하지 마시고, sudo sudo usermod -aG docker $USER 명령어로 현재 유저가 docker를 실행할 수 있도록 그룹에 추가해주세요. 그 후 volumes 내 postgres 폴더 삭제, docker rm db로 컨테이너 삭제, 이후 다시 docker compose up으로 띄워보시기 바랍니다 On Mar 16, 2023 14:21 +0900, Jaewook-Lee @.***>, wrote:

docker-compose up 이 sudo 권한을 요구해서 sudo docker-compose up을 실행하니 아래와 같은 에러를 얻었습니다. db | Error: Database is uninitialized and superuser password is not specified. db | You must specify POSTGRES_PASSWORD to a non-empty value for the db | superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run". db | db | You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all db | connections without a password. This is not recommended. db | db | See PostgreSQL documentation about "trust": db | https://www.postgresql.org/docs/current/auth-trust.html .envrc에서 환경 변수 값들을 다 1234로 설정했는데 super user에 대해서도 따로 설정해야 하나요? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because your review was requested.Message ID: @.***>

Binsk-dev commented 1 year ago

@Jaewook-Lee @PricelessCode schema & table이 정상적으로 생성되면 Review 했다고 ✅ ㄱㄱㄱㄱ

Jaewook-Lee commented 1 year ago

저... docker exec -it db sh로 들어가서 psql -h localhost -f model.sql 치는거 까지는 했는데... sql문을 어디에 치나요? # select * from Opinion 치니까 sh: 2: select: not found라고 뜨네요.

ChangHoon-Sung commented 1 year ago

# select * from Opnion 치니까 sh: 2: select: not found라고 뜨네요.

Opinion..

Jaewook-Lee commented 1 year ago

코멘트 입력 과정에 오타가 있었습니다. 테스트 할 때는 오타 없었습니다.

ChangHoon-Sung commented 1 year ago

DBeaver와 같은 별도의 DB 클라이언트를 사용해보겠어요? On Mar 17, 2023 09:04 +0900, Jaewook-Lee @.***>, wrote:

코멘트 입력 과정에 오타가 있었습니다. 테스트 할 때는 오타 없었습니다. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because your review was requested.Message ID: @.***>

seungholee-dev commented 1 year ago

후딱 체크 중입니다. 일을 하느라 어제 체크를 못했어요 ;~;