Skip to content

Commit 8e9b7c1

Browse files
authored
Merge pull request #265 from jswir/docs-state-persistence
docs: add State Persistence section to publishing guide
2 parents 8ba5332 + a86090d commit 8e9b7c1

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

src/documentation/user_guides/publishing/publishing.malloynb

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,59 @@ See the [REST API](rest_api.malloynb) documentation for all available endpoints.
187187

188188
---
189189

190+
## State Persistence
191+
192+
Publisher persists configuration changes in a local DuckDB database (`publisher.db`). This means changes made via the REST API—adding projects, packages, or connections—survive server restarts.
193+
194+
### How It Works
195+
196+
1. **First start**: Publisher reads `publisher.config.json` and syncs it to `publisher.db`
197+
2. **Subsequent starts**: Publisher loads from the database, ignoring config file changes
198+
3. **API changes**: Adding/removing projects, packages, or connections updates the database
199+
200+
### Reinitializing from Config
201+
202+
To reset the database and reload from `publisher.config.json`:
203+
204+
```bash
205+
npx @malloy-publisher/server --init --server_root .
206+
```
207+
208+
Use `--init` when:
209+
- You've updated `publisher.config.json` and want those changes applied
210+
- You want to reset to the original configuration
211+
- You're troubleshooting configuration issues
212+
213+
### Mutable vs Frozen Configuration
214+
215+
By default, Publisher allows configuration changes via the API. To lock the configuration (e.g., in production):
216+
217+
```json
218+
{
219+
"frozenConfig": true,
220+
"projects": [...]
221+
}
222+
```
223+
224+
When `frozenConfig: true`:
225+
- API endpoints that modify configuration return errors
226+
- The UI hides add/edit/delete controls
227+
- Only the config file (with `--init`) can change the setup
228+
229+
### Storage Location
230+
231+
Publisher creates these files in your `--server_root` directory:
232+
233+
```
234+
my-server-root/
235+
├── publisher.config.json # Initial configuration
236+
├── publisher.db # Persisted state (DuckDB)
237+
├── publisher.db.wal # Database write-ahead log
238+
└── publisher_data/ # Downloaded packages (from GitHub, etc.)
239+
```
240+
241+
---
242+
190243
## Next Steps
191244

192245
Your models are published. Build consumption experiences:

0 commit comments

Comments
 (0)