pgsqlio 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/readme.md +106 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pgsqlio",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Interactive PostgreSQL dump, restore, and cleanup CLI (OpenTUI)",
5
5
  "type": "module",
6
6
  "bin": {
@@ -32,7 +32,7 @@
32
32
  "license": "MIT",
33
33
  "repository": {
34
34
  "type": "git",
35
- "url": "git+https://github.com/kingRayhan/pg_backup.git"
35
+ "url": "git+https://github.com/kingRayhan/pgsqlio.git"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/node": "^22.20.2",
package/readme.md CHANGED
@@ -1,30 +1,119 @@
1
1
  # pgsqlio
2
2
 
3
- Interactive PostgreSQL dump, restore, and cleanup CLI built with [OpenTUI](https://opentui.com).
3
+ Interactive CLI for PostgreSQL dump, restore, cleanup, and dropping databases.
4
4
 
5
- Requires:
6
- - [Bun](https://bun.sh) ≥ 1.3 (recommended) **or** Node.js ≥ 26.4 with `--experimental-ffi`
7
- - [PostgreSQL client tools](https://www.postgresql.org/download/) (`pg_dump`, `psql`)
5
+ ```bash
6
+ npx pgsqlio
7
+ # or
8
+ bunx pgsqlio
9
+ ```
10
+
11
+ ![pgsqlio](./assets/cli.png)
12
+
13
+ Requires [Bun](https://bun.sh) ≥ 1.3 (recommended) or Node.js ≥ 26.4, plus `pg_dump` and `psql` on your `PATH`.
14
+
15
+ ---
8
16
 
9
- ## Run
17
+ ## Quick start
10
18
 
11
19
  ```bash
12
- bun dist/cli.js
13
- # or during development:
14
- bun src/cli.ts
20
+ bunx pgsqlio
21
+ ```
22
+
23
+ You’ll get a terminal UI with sticky branding and a menu. Use ↑/↓ and Enter. Esc goes back. Ctrl+C quits.
24
+
25
+ Connection URLs work with or without a database name:
26
+
27
+ ```text
28
+ postgresql://user:password@host:5432
29
+ postgresql://user:password@host:5432/mydb
30
+ postgresql://postgres@127.0.0.1
31
+ ```
32
+
33
+ ---
34
+
35
+ ## Commands (interactive menu)
36
+
37
+ There are no subcommands — start `pgsqlio` and pick an action.
38
+
39
+ ### Dump
40
+
41
+ Backup one or more databases.
42
+
43
+ 1. Enter connection URL
44
+ 2. **All databases** or **Select databases**
45
+ 3. If multiple: **Separate files** or **Single file**
46
+ 4. Watch per-database progress
47
+
48
+ | Mode | Output |
49
+ | -------- | ------------------------------------- |
50
+ | Separate | `backup_<dbname>_YYYYMMDD_HHMMSS.sql` |
51
+ | Single | `backup_combined_YYYYMMDD_HHMMSS.sql` |
52
+
53
+ Combined files create missing databases on restore and switch with `\connect`. Dumps include `--clean --if-exists`.
54
+
55
+ ---
56
+
57
+ ### Restore
58
+
59
+ Import a `.sql` backup.
60
+
61
+ 1. Enter connection URL
62
+ 2. Enter path to the `.sql` file
63
+ 3. Choose how to apply:
64
+
65
+ | Option | When to use |
66
+ | ------------------------------ | --------------------------------------------------------- |
67
+ | **Wipe schemas, then restore** | Target already has objects / retry after a failed restore |
68
+ | **Restore as-is** | Empty databases |
69
+
70
+ Combined dumps: missing DBs are created automatically, then the file is loaded.
71
+
72
+ ---
73
+
74
+ ### Cleanup
75
+
76
+ Empty one database’s `public` schema (keeps the database).
77
+
78
+ 1. Enter URL **including** `/dbname`
79
+ 2. Confirm
80
+
81
+ Runs:
82
+
83
+ ```sql
84
+ DROP SCHEMA public CASCADE;
85
+ CREATE SCHEMA public;
15
86
  ```
16
87
 
17
- Do **not** use `node dist/cli.js` on Node &lt; 26 — OpenTUI needs Bun (or Node ≥ 26.4 with FFI).
88
+ ---
89
+
90
+ ### Drop databases
91
+
92
+ Permanently delete selected databases.
93
+
94
+ 1. Enter connection URL
95
+ 2. Select databases (checkboxes)
96
+ 3. Confirm
97
+
98
+ Active connections are terminated first. `postgres` and `template*` cannot be dropped.
99
+
100
+ ---
101
+
102
+ ## Keyboard
18
103
 
19
- Opens a menu:
104
+ | Key | Action |
105
+ | ------ | ------------------ |
106
+ | ↑ / ↓ | Move |
107
+ | Enter | Confirm |
108
+ | Space | Toggle checkbox |
109
+ | a | Select all (lists) |
110
+ | Esc | Back |
111
+ | Ctrl+C | Quit |
20
112
 
21
- 1. **Dump** — enter URL → all or select databases → progress spinners
22
- 2. **Restore** — enter URL + `.sql` path → confirm
23
- 3. **Cleanup** — enter URL → confirm destructive reset
24
- 4. **Quit**
113
+ ---
25
114
 
26
115
  ## Notes
27
116
 
28
- - The DB user needs sufficient privileges.
29
- - Dump backups are written as `backup_<dbname>_YYYYMMDD_HHMMSS.sql`.
30
- - Esc goes back; Ctrl+C quits.
117
+ - Use a role with rights to dump, create, and drop as needed.
118
+ - Prefer **Wipe schemas, then restore** if you see “already exists” errors.
119
+ - Host-only URLs (no `/dbname`) are fine for Dump / Drop; Cleanup needs a specific database in the URL.