mirror of
https://github.com/penpot/penpot.git
synced 2026-07-20 21:17:44 +00:00
📎 Add postgresql client tool wrapper for devenv
This commit is contained in:
parent
d656d342fe
commit
8b734d9844
@ -39,6 +39,9 @@ Backend RPC command areas without focused memories include access tokens, binfil
|
||||
|
||||
Database migrations live in `backend/src/app/migrations/`; pure SQL migrations are under `backend/src/app/migrations/sql/`. SQL filenames conventionally start with a sequence and verb/table description, e.g. `0026-mod-profile-table-add-is-active-field`. Applied migrations are tracked in the `migrations` table.
|
||||
|
||||
For interactive PostgreSQL access with correct dev defaults, use `tools/psql`; to dump
|
||||
the current DDL schema, use `tools/db-schema` (see `mem:tools/psql`).
|
||||
|
||||
For deeper details on transaction semantics, advisory locks, Transit vs JSON helpers, and dev/test DB URLs: `mem:backend/rpc-db-worker-subtleties`.
|
||||
|
||||
## Background tasks
|
||||
|
||||
@ -45,7 +45,8 @@ module. You can read it from `mem:<MODULE>/core`
|
||||
tmux session lifecycle, MinIO provisioning, or anything in `manage.sh`'s
|
||||
`*-devenv` commands, read `mem:devenv/core`.
|
||||
- `tools/` contains standalone dev utilities: `nrepl-eval.mjs` (backend REPL eval),
|
||||
`paren-repair.bb` (delimiter-error fixer, see `mem:tools/paren-repair`), and
|
||||
`paren-repair.bb` (delimiter-error fixer, see `mem:tools/paren-repair`),
|
||||
`psql` / `db-schema` (PostgreSQL client and schema dump wrappers, see `mem:tools/psql`), and
|
||||
`taiga.py` / `gh.py` (issue management helpers).
|
||||
- `experiments/` contains standalone experimental HTML/JS/scripts; treat it as non-core unless the user explicitly asks about it.
|
||||
- `sample_media/` contains sample image/icon media and config used as fixtures/demo material; do not infer app behavior from it.
|
||||
|
||||
51
.serena/memories/tools/psql.md
Normal file
51
.serena/memories/tools/psql.md
Normal file
@ -0,0 +1,51 @@
|
||||
# PostgreSQL client wrapper
|
||||
|
||||
`tools/psql` is a wrapper around the `psql` command with defaults preconfigured
|
||||
for the Penpot development environment.
|
||||
|
||||
## When to use
|
||||
|
||||
- Running SQL queries against the dev database (`penpot`) or test database
|
||||
(`penpot_test`).
|
||||
- Inspecting table structures, running migrations manually, or debugging
|
||||
database state.
|
||||
- Any time you need PostgreSQL access and want the correct host/user/password
|
||||
without typing them each time.
|
||||
|
||||
## How to use
|
||||
|
||||
```bash
|
||||
# Interactive session (penpot database)
|
||||
tools/psql
|
||||
|
||||
# Interactive session (penpot_test database)
|
||||
tools/psql --test
|
||||
|
||||
# Inline query (penpot)
|
||||
tools/psql -c "SELECT 1"
|
||||
|
||||
# Inline query (penpot_test)
|
||||
tools/psql --test -c "SELECT 1"
|
||||
|
||||
# Override defaults
|
||||
tools/psql -h other-host -U other-user -d other-db
|
||||
|
||||
# Pipe SQL from a file
|
||||
tools/psql -f some-query.sql
|
||||
```
|
||||
|
||||
All standard `psql` flags are passed through after the wrapper's own flags.
|
||||
|
||||
## Defaults
|
||||
|
||||
| Setting | Default | Env override |
|
||||
|----------|-----------|---------------------|
|
||||
| Host | `postgres` | `PENPOT_DB_HOST` |
|
||||
| User | `penpot` | `PENPOT_DB_USER` |
|
||||
| Password | `penpot` | `PENPOT_DB_PASSWORD` |
|
||||
| Database | `penpot` | `PENPOT_DB_NAME` |
|
||||
|
||||
## See also
|
||||
|
||||
`tools/db-schema` — a companion script that dumps the current DDL schema
|
||||
using `pg_dump --schema-only`, with the same defaults and `--test` flag.
|
||||
34
tools/db-schema
Executable file
34
tools/db-schema
Executable file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
HOST="${PENPOT_DB_HOST:-postgres}"
|
||||
USER="${PENPOT_DB_USER:-penpot}"
|
||||
PASSWORD="${PENPOT_DB_PASSWORD:-penpot}"
|
||||
DB="${PENPOT_DB_NAME:-penpot}"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--test)
|
||||
DB="penpot_test"
|
||||
shift
|
||||
;;
|
||||
--host|-h)
|
||||
HOST="$2"
|
||||
shift 2
|
||||
;;
|
||||
--user|-U)
|
||||
USER="$2"
|
||||
shift 2
|
||||
;;
|
||||
--db|-d)
|
||||
DB="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
export PGPASSWORD="$PASSWORD"
|
||||
exec pg_dump -h "$HOST" -U "$USER" -d "$DB" --schema-only --no-owner --no-privileges "$@"
|
||||
34
tools/psql
Executable file
34
tools/psql
Executable file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
HOST="${PENPOT_DB_HOST:-postgres}"
|
||||
USER="${PENPOT_DB_USER:-penpot}"
|
||||
PASSWORD="${PENPOT_DB_PASSWORD:-penpot}"
|
||||
DB="${PENPOT_DB_NAME:-penpot}"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--test)
|
||||
DB="penpot_test"
|
||||
shift
|
||||
;;
|
||||
--host|-h)
|
||||
HOST="$2"
|
||||
shift 2
|
||||
;;
|
||||
--user|-U)
|
||||
USER="$2"
|
||||
shift 2
|
||||
;;
|
||||
--db|-d)
|
||||
DB="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
export PGPASSWORD="$PASSWORD"
|
||||
exec psql -h "$HOST" -U "$USER" -d "$DB" "$@"
|
||||
Loading…
x
Reference in New Issue
Block a user