From 7a950ac1c9118cc2baed38288c66a005c937632d Mon Sep 17 00:00:00 2001
From: Tianwen Chen <tchen@gitlab.com>
Date: Mon, 4 Nov 2024 12:36:44 +0000
Subject: [PATCH 1/2] Update pgai doc with latest setup

---
 doc/development/database/database_lab_pgai.md | 37 ++++++++++---------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/doc/development/database/database_lab_pgai.md b/doc/development/database/database_lab_pgai.md
index d7709e21a4bfda..9b3da210f6b561 100644
--- a/doc/development/database/database_lab_pgai.md
+++ b/doc/development/database/database_lab_pgai.md
@@ -23,41 +23,44 @@ you can follow the steps below to configure the `pgai` Gem:
       A dialog with everything that's needed for configuration appears, using this format:
 
       ```shell
-      dblab init --url "http://127.0.0.1:1234" --token TOKEN --environment-id <environment-id>
+      dblab init --url "http://127.0.0.1:<local-port>" --token TOKEN --environment-id <environment-id>
       ```
 
       ```shell
-      ssh -NTML 1234:localhost:<environment-port> <postgresai-user>@<postgresai-proxy> -i ~/.ssh/id_rsa
+      ssh -NTML <local-port>:localhost:<instance-port> <instance-host> -i ~/.ssh/id_rsa
       ```
 
 1. Add the following snippet to your SSH configuration file at `~/.ssh/config`, replacing the variable values:
 
    ```plaintext
-   # lab servers
-   Host <postgresai-servers>
-     User <postgresai-user>
-     IdentityFile ~/.ssh/id_ed25519
-
-   # lab boxes
-   Host <postgresai-servers>
-     User <postgresai-user>
-     PreferredAuthentications publickey
-     IdentityFile ~/.ssh/id_ed25519
-     ProxyCommand ssh <postgresai-servers> -W %h:%p
+   Host lb-bastion.db-lab.gitlab.com
+   User <postgresai-user>
+   IdentitiesOnly yes
+   IdentityFile ~/.ssh/id_ed25519
+
+   Host *.gitlab-db-lab.internal
+   User <postgresai-user>
+   PreferredAuthentications publickey
+   IdentitiesOnly yes
+   IdentityFile ~/.ssh/id_ed25519
+   ProxyCommand ssh lb-bastion.db-lab.gitlab.com -W %h:%p
    ```
 
+   > See original setup from [Access the console with `psql`](database_lab.md#access-the-console-with-psql)
+
 1. Run the following commands:
 
    ```shell
    gem install pgai
 
-   # Grab an access token: https://console.postgres.ai/gitlab/tokens
-   # GITLAB_USER is your GitLab handle
-   pgai config --prefix=$GITLAB_USER
+   # 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 <environment-id> --port <environment-port> -n <database_name>
+   # NOTE: use `2345` as the <instance-port> for Gitlab instances
+   pgai env add --alias main --id <instance-host> --port <instance-port> -n <database_name>
    ```
 
 1. Once this one-time configuration is done, you can use `pgai connect` to connect to a particular database. For
-- 
GitLab


From 79ec7defabadeab9913c7a85dfe5e44a097c66b4 Mon Sep 17 00:00:00 2001
From: Tianwen Chen <tchen@gitlab.com>
Date: Tue, 5 Nov 2024 21:35:09 +1100
Subject: [PATCH 2/2] Remove the config and unnecessary comment related to
 instance port

---
 doc/development/database/database_lab_pgai.md | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)

diff --git a/doc/development/database/database_lab_pgai.md b/doc/development/database/database_lab_pgai.md
index 9b3da210f6b561..7ebdcf61a9c647 100644
--- a/doc/development/database/database_lab_pgai.md
+++ b/doc/development/database/database_lab_pgai.md
@@ -30,23 +30,7 @@ you can follow the steps below to configure the `pgai` Gem:
       ssh -NTML <local-port>:localhost:<instance-port> <instance-host> -i ~/.ssh/id_rsa
       ```
 
-1. Add the following snippet to your SSH configuration file at `~/.ssh/config`, replacing the variable values:
-
-   ```plaintext
-   Host lb-bastion.db-lab.gitlab.com
-   User <postgresai-user>
-   IdentitiesOnly yes
-   IdentityFile ~/.ssh/id_ed25519
-
-   Host *.gitlab-db-lab.internal
-   User <postgresai-user>
-   PreferredAuthentications publickey
-   IdentitiesOnly yes
-   IdentityFile ~/.ssh/id_ed25519
-   ProxyCommand ssh lb-bastion.db-lab.gitlab.com -W %h:%p
-   ```
-
-   > See original setup from [Access the console with `psql`](database_lab.md#access-the-console-with-psql)
+1. To configure `ssh`, follow the instruction at [Access the console with `psql`](database_lab.md#access-the-console-with-psql), replacing `${USER}` with your postgres.ai username.
 
 1. Run the following commands:
 
@@ -59,7 +43,6 @@ you can follow the steps below to configure the `pgai` Gem:
 
    # 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)
-   # NOTE: use `2345` as the <instance-port> for Gitlab instances
    pgai env add --alias main --id <instance-host> --port <instance-port> -n <database_name>
    ```
 
-- 
GitLab