You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(dev): add --preview-db=N flag to nix run .#dev
Connects to the database used by an opencouncil preview deployment.
Detects whether the PR has an isolated DB (SSH tunnel) or uses
the shared staging DB (reads URL from server), and forces external
DB mode to skip local postgres.
Requires OC_PREVIEW_SSH to be set to the preview server SSH target.
Can be used independently or alongside --preview-tasks=M.
Copy file name to clipboardExpand all lines: docs/nix-usage.md
+42Lines changed: 42 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,6 +93,48 @@ When `TASK_API_URL` is configured in `.env`, the dev runner will check if the ta
93
93
⚠ Task server not reachable (start it separately for E2E testing)
94
94
```
95
95
96
+
### Preview Database (--preview-db=N)
97
+
98
+
When testing against a preview deployment's database locally (e.g., running cron jobs or admin tools against a PR's data), use `--preview-db=N` where N is the **opencouncil** PR number:
99
+
100
+
```bash
101
+
nix run .#dev -- --preview-db=193
102
+
```
103
+
104
+
Can be combined with `--preview-tasks=M` to also connect to a tasks preview (where M is the **opencouncil-tasks** PR number):
105
+
106
+
```bash
107
+
nix run .#dev -- --preview-db=193 --preview-tasks=26
108
+
```
109
+
110
+
**Prerequisites:**
111
+
-`OC_PREVIEW_SSH` must be set to the SSH target for the preview server:
112
+
```bash
113
+
# In .env or exported
114
+
OC_PREVIEW_SSH=root@159.89.98.26
115
+
```
116
+
- Your SSH key must be in the server's `authorized_keys`
117
+
118
+
**How it works:**
119
+
120
+
The flag detects whether the PR has an isolated database (migration PRs with `.has-local-db` marker) or uses the shared staging database:
121
+
122
+
-**Isolated DB**: Opens an SSH tunnel to the per-PR PostgreSQL instance on the server
123
+
-**Shared staging DB**: Reads `DATABASE_URL` from the server's `.env` and uses it directly
124
+
125
+
In both cases, the local postgres is skipped (`--db=external` mode is forced).
The SSH tunnel is automatically cleaned up when the dev server exits.
137
+
96
138
### Mobile Preview (QR code for phone testing)
97
139
98
140
The dev server binds to `0.0.0.0` by default, making it accessible from other devices on the same Wi-Fi. Click the **QR button** next to the DEV panel (bottom-right) to see a QR code encoding the LAN URL for the current page.
0 commit comments