From c3a407286a7c7cd7ea5b8f8535f7ffb01d87478e Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 23 Nov 2026 22:19:42 +0000 Subject: [PATCH] :books: Clarify PostgreSQL wrapper destinations Document workspace test database selection and correct the default host and tool limitations to prevent queries against the wrong database. AI-assisted-by: gpt-6.1-terra --- .serena/memories/scripts/psql.md | 50 +++----------------------------- 1 file changed, 4 insertions(+), 46 deletions(-) diff --git a/.serena/memories/scripts/psql.md b/.serena/memories/scripts/psql.md index 8b527cb0c6..016ef5fb9b 100644 --- a/.serena/memories/scripts/psql.md +++ b/.serena/memories/scripts/psql.md @@ -1,47 +1,5 @@ -# Psql +# PostgreSQL wrappers -`scripts/psql` is a wrapper around `psql` that connects to the Penpot PostgreSQL -database using environment variables (`PENPOT_DB_HOST`, `PENPOT_DB_USER`, -`PENPOT_DB_PASSWORD`, `PENPOT_DB_NAME`) with sensible defaults for local -development. - -## When to use - -- Running ad-hoc SQL queries against the Penpot database. -- Inspecting schema, migrations, or data during development or debugging. - -## How to use (CLI) - -```bash -# Default connection (penpot db, localhost) -scripts/psql -c "SELECT version();" - -# Test database (ws0) -scripts/psql --test -c "SELECT * FROM migrations;" - -# Isolated test database of another instance (ws1+) -scripts/psql --test --ws 1 -c "SELECT * FROM migrations;" - -# Custom host/user/database -scripts/psql --host myhost --user myuser --db mydb -``` - -`--ws N` only applies together with `--test` (the main database is -shared by all instances): it selects `penpot_test` on `--ws 0` and -`penpot_test_wsN` on `--ws N`. `scripts/db-schema` accepts the same flags. - -`scripts/psql` must be invoked from the repo root so the path resolves. - -## Native Tool Available (OpenCode V2) - -A native OpenCode V2 tool `penpot-psql` is available. It is defined in -`.opencode/plugins/penpot.js` and registered through `setup()`. The LLM can -call it directly with: -- `sql`: SQL command string to execute -- `test`: Boolean flag to use the `penpot_test` database - -Example usage by the LLM: -``` -penpot-psql(sql="SELECT version();") -penpot-psql(sql="SELECT * FROM migrations;", test=true) -``` +- `scripts/psql` invokes `psql`; `scripts/db-schema` invokes schema-only `pg_dump`. Both use `PENPOT_DB_HOST`, `PENPOT_DB_USER`, `PENPOT_DB_PASSWORD` and `PENPOT_DB_NAME`, not the backend test URI. The default host is `postgres`; check the effective destination before executing SQL. +- Both wrappers accept `--test --ws N` (also `--ws wsN`): workspace 0 selects `penpot_test`, and workspace N selects `penpot_test_wsN`. `--ws` without `--test` is rejected because the main database is shared. Check the actual `PENPOT_TEST_DATABASE_URI` for the workspace rather than assuming the wrapper's defaults match it; see `mem:devenv/core`. +- The `penpot-psql` tool's `test` option selects `penpot_test`; it has no workspace selector. Consult the active tool catalog for its invocation and use the wrapper or another explicitly configured client when the target differs.