EnableInPostgreSQL installs triggers for the following extensions into every database: - postgis - postgis_topology - fuzzystrmatch - postgis_tiger_geocoder
(ctx context.Context, exec postgres.Executor)
| 18 | // - fuzzystrmatch |
| 19 | // - postgis_tiger_geocoder |
| 20 | func EnableInPostgreSQL(ctx context.Context, exec postgres.Executor) error { |
| 21 | log := logging.FromContext(ctx) |
| 22 | |
| 23 | stdout, stderr, err := exec.ExecInAllDatabases(ctx, |
| 24 | strings.Join([]string{ |
| 25 | // Quiet NOTICE messages from IF NOT EXISTS statements. |
| 26 | // - https://www.postgresql.org/docs/current/runtime-config-client.html |
| 27 | `SET client_min_messages = WARNING;`, |
| 28 | |
| 29 | // Do not wait for changes to be replicated. [Since PostgreSQL v9.1] |
| 30 | // - https://www.postgresql.org/docs/current/runtime-config-wal.html |
| 31 | `SET synchronous_commit = LOCAL;`, |
| 32 | |
| 33 | `CREATE EXTENSION IF NOT EXISTS postgis;`, |
| 34 | `CREATE EXTENSION IF NOT EXISTS postgis_topology;`, |
| 35 | `CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;`, |
| 36 | `CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;`, |
| 37 | }, "\n"), |
| 38 | map[string]string{ |
| 39 | "ON_ERROR_STOP": "on", // Abort when any one statement fails. |
| 40 | "QUIET": "on", // Do not print successful statements to stdout. |
| 41 | }) |
| 42 | |
| 43 | log.V(1).Info("enabled PostGIS and related extensions", "stdout", stdout, "stderr", stderr) |
| 44 | |
| 45 | return err |
| 46 | } |