pgai Ruby 젬을 사용한 Database Lab 접근
GitLab v19.4요약
@mbobin 이 만든 pgai Ruby Gem은 데이터베이스 클론 접근을 크게 단순화하며, 다음을 지원합니다. pgai gem을 설정하는 방법은 다음과 같습니다. 먼저 Postgres.ai instances page에서 몇 가지 값을 수집해야 합니다.
@mbobin 이 만든 pgai Ruby Gem은
데이터베이스 클론 접근을 크게 단순화하며, 다음을 지원합니다.
- Postgres.ai instances page에 나열된 모든 데이터베이스 클론에 접근.
- 동일한 클론에서 여러 개의
psql세션 사용.
사전 요구 사항#
- Database Lab에 대한
AllFeaturesUserpsql접근 권한. - 1Password CLI (
op) 설치 및 1Password 계정 로그인.
pgai gem을 설정하는 방법은 다음과 같습니다.
-
먼저 Postgres.ai instances page에서 몇 가지 값을 수집해야 합니다.
-
설정하려는 인스턴스로 이동한 다음 화면 오른쪽을 확인합니다.
-
Connection에서 Connect를 선택합니다. 메뉴가 접혀 있을 수 있습니다.
설정에 필요한 모든 정보가 담긴 대화 상자가 다음 형식으로 나타납니다.
dblab init --url "http://127.0.0.1:<local-port>" --token TOKEN --environment-id <environment-id>ssh -NTML <local-port>:localhost:<instance-port> <instance-host> -i ~/.ssh/id_rsa
-
-
ssh를 설정하려면psql로 콘솔 접근의 안내를 따르며,${USER}를 본인의 postgres.ai 사용자 이름으로 바꿉니다. -
다음 명령을 실행합니다.
gem install pgai # Generate an encryption key and store it in 1Password pgai enc keygen # Before running the following command, # grab an access token from https://console.postgres.ai/gitlab/tokens pgai config --prefix=<postgresai-user> # Grab the respective port values from https://console.postgres.ai/gitlab/instances # for the instances you'll be using (in this case, for the `main` database instance) pgai env add --alias main --id <instance-host> --port <instance-port> -n gitlabhq_dblab -
이 일회성 설정을 마치면
pgai connect로 특정 데이터베이스에 연결할 수 있습니다. 예를 들어main데이터베이스에 연결하려면 다음과 같이 실행합니다.pgai connect main -
클론 사용을 마치면 다음과 같이 삭제할 수 있습니다.
pgai destroy main