|
| 1 | +# Demo Data |
| 2 | + |
| 3 | +Demo data in pum allows you to provide sample datasets that can be loaded into your database for testing, development, or demonstration purposes. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +Demo data is defined in your [configuration file](configuration.md) using the `demo_data` section. You basically provide an SQL file (or multiple SQL files) to fill the data. These SQL files are typically generated using `pg_dump` with specific options to export only the data you want to include. |
| 8 | + |
| 9 | +## Configuration |
| 10 | + |
| 11 | +Demo data is configured using the [`DemoDataModel`](../api/config_model.md#demodatamodel) in your `.pum.yaml` configuration file. Each demo dataset requires: |
| 12 | + |
| 13 | +- **name**: A descriptive name for the demo dataset |
| 14 | +- **file**: Path to a single SQL file containing the demo data |
| 15 | +- **files**: List of paths to multiple SQL files (use either `file` or `files`, not both) |
| 16 | + |
| 17 | +### Single File Example |
| 18 | + |
| 19 | +```yaml |
| 20 | +demo_data: |
| 21 | + - name: some cool demo dataset |
| 22 | + file: demo_data/demo_data.sql |
| 23 | +``` |
| 24 | +
|
| 25 | +### Multiple Files Example |
| 26 | +
|
| 27 | +```yaml |
| 28 | +demo_data: |
| 29 | + - name: some cool demo dataset |
| 30 | + files: |
| 31 | + - demo_data/demo_data_1.sql |
| 32 | + - demo_data/demo_data_2.sql |
| 33 | +``` |
| 34 | +
|
| 35 | +## Creating Demo Data Files |
| 36 | +
|
| 37 | +To create demo data SQL files, use `pg_dump` with the following options: |
| 38 | + |
| 39 | +```bash |
| 40 | +pg_dump --inserts --data-only --no-owner --no-privileges --schema=YOUR_DATA_SCHEMA > demo_data.sql |
| 41 | +``` |
| 42 | + |
| 43 | +**Options explained:** |
| 44 | +- `--inserts`: Use INSERT commands instead of COPY (more portable) |
| 45 | +- `--data-only`: Export only data, not schema definitions |
| 46 | +- `--no-owner`: Don't include ownership information |
| 47 | +- `--no-privileges`: Don't include privilege information |
| 48 | +- `--schema=YOUR_DATA_SCHEMA`: Export data only from the specified schema |
| 49 | + |
| 50 | +Replace `YOUR_DATA_SCHEMA` with the name of your schema containing the demo data you want to export. |
0 commit comments