mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-17 02:53:51 +08:00
This PR removes the need to run setup_timescaledb. It also fixes pg_dump and pg_restore. Previously, the database would restore in a broken state because trigger functions were never attached to meta tables (since setup_timescaledb() was not run). However, attaching those triggers at extension creation also causes problems since the data copy happens after extension creation but we don't want triggers fired on the data restored (that could cause duplicate rows, for example). The solution to this chicken-and-egg problem in this PR is to have a special configuration (GUC) variable `timescaledb.restoring` that, if 'on', would prevent the extension from attaching triggers at extension creation. Then, after restoration, you'd call restore_timescaledb() to attach the triggers and unset the GUC above. This procedure is documented in the README as part of this PR.
19 lines
338 B
Bash
Executable File
19 lines
338 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
if [[ -z "$DB_NAME" ]]; then
|
|
echo "The DB_NAME must be set"
|
|
exit 1
|
|
fi
|
|
|
|
# Create data directories for tablespaces tests
|
|
psql -h localhost -U postgres -v ON_ERROR_STOP=1 << EOF
|
|
\echo 'Creating database: ${DB_NAME}'
|
|
CREATE DATABASE ${DB_NAME};
|
|
|
|
\c ${DB_NAME}
|
|
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
|
|
|
EOF
|