Skip to content

Commit bc2e5f5

Browse files
committed
Add pg_dump step, improve Sqitch deployment, improve docs
1 parent cb57910 commit bc2e5f5

File tree

4 files changed

+30
-25
lines changed

4 files changed

+30
-25
lines changed

db/deploy/001.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,12 @@ COMMENT ON FUNCTION geofaker.n_points_in_polygon(GEOMETRY, INT) IS 'Creates N po
292292

293293

294294

295-
-- Call the procedure to ensure the required temp table exists, avoids deploy failure
296-
CALL geofaker.point_in_place_landuse();
295+
-- Ensure the required temp table exists, avoids deploy failure on next sproc
296+
CREATE TEMP TABLE IF NOT EXISTS faker_store_location
297+
(
298+
store_id BIGINT, place_osm_id BIGINT, place_osm_type TEXT, place_name TEXT,
299+
road_osm_id BIGINT, geom GEOMETRY
300+
);
297301

298302

299303
CREATE PROCEDURE geofaker.points_around_point()

docs/src/customize.md

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,6 @@ This section builds on the [Quick Start](quick-start.md) section.
55
> Warning: This project is in early development! Things will be changing over the first few releases (e.g. before 0.5.0).
66
77

8-
## External Postgres connections
9-
10-
The quick start uses the built-in Postgres/PostGIS instance. See
11-
the PgOSM Flex section on [Using external Postgres connections](https://pgosm-flex.com/postgres-external.html) to use your own Postgres instance.
12-
This approach does load a lot of data to the target database which may not be
13-
desired. Consider using `pg_dump` to load only the target data to your
14-
database of choice.
15-
16-
The Sqitch deployment step should use additional parameters not set in the quick start
17-
instructions.
18-
19-
```bash
20-
source ~/.pgosm-faker-local
21-
cd pgosm-flex-faker/db
22-
sqitch db:pg://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:$POSTGRES_PORT/$POSTGRES_DB deploy
23-
```
24-
258

269
## Each time is new data
2710

@@ -54,3 +37,13 @@ UNION
5437
SELECT 'vineyard' AS osm_type
5538
;
5639
```
40+
41+
42+
## External Postgres connections
43+
44+
Geo Faker currently does not support running directly into an external database.
45+
Technically it can be operated that way, but the instructions and helper scripts
46+
are specific to using the in-Docker database.
47+
48+
Use `--pg-dump` to extract the generated data.
49+

docs/src/quick-start.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,18 @@ docker exec -it \
4949
## Load and Run Faker Objects
5050

5151
After the data completes processing, load the Geo Faker database structures
52-
in the `geofaker` schema.
53-
This is done using Sqitch.
52+
in the `geofaker` schema. This deploys the functions and procedures needed,
53+
runs the processing, and runs `pg_dump` saving the faked
54+
data into `~/pgosm-data/geofaker_stores_customers.sql`.
5455

5556

5657
```bash
5758
docker exec -it geofaker /bin/bash run_faker.sh
5859
```
5960

60-
Connect to the database and call this stored procedure. The generated data
61-
is left in a temp table, each run of the stored procedure will produce new,
62-
random results.
61+
Load the saved data into a database of your choice.
62+
63+
```bash
64+
psql -d pgosm_faker -f ~/pgosm-data/geofaker_stores_customers.sql
65+
```
66+

run_faker.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#!/bin/bash
22
echo 'Deploying geofaker schema via Sqitch...'
33
cd /app/faker/db
4-
sqitch db:pg://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/pgosm deploy
4+
sqitch db:pg://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost/pgosm deploy
55

66
echo 'Running GeoFaker generation...'
77
psql -d postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost/pgosm \
88
-f /app/run_faker.sql
9+
10+
echo 'Running pg_dump...'
11+
pg_dump -d postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost/pgosm \
12+
-n geofaker -f /app/output/geofaker_stores_customers.sql

0 commit comments

Comments
 (0)