-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify how to use pg_dump & pg_restore with periods #35
Comments
Generally, pg_dump/pg_restore want the target database to be empty. The |
Ok, I understand that What remains then, is the problem described in #22, which happens even without $> psql <<EOF
CREATE DATABASE test;
\c test
create extension periods cascade;
create table test (id int not null primary key);
select periods.add_system_time_period('test');
select periods.add_system_versioning('test');
EOF
# [... psql output ...]
$> pg_dump -F c -d test -f test.psql
$> psql -c 'DROP DATABASE test;' -c 'CREATE DATABASE test;'
$> pg_restore -F c -d test --single-transaction test.psql
pg_restore: error: could not execute query: FEHLER: cannot grant DELETE to "public.test_history"; history objects are read-only
CONTEXT: PL/pgSQL-Funktion periods.health_checks() Zeile 138 bei RAISE
Command was: REVOKE USAGE ON SCHEMA public FROM PUBLIC;
GRANT ALL ON SCHEMA public TO PUBLIC; Even after some trying around I yet wasn't able to make
|
Can we clarify whether this only happens with |
Relating to #22, I've recently stumbled over the problem of "how to dump & restore system versioned tables".
My personal preference of
pg_dump --format=custom --file=dump.psql my_source_database
&pg_restore --format=custom --clean --if-exists --single-transcation -d my_target_database
doesn't seem to work with periods, as it doesn't seem to like, howpg_restore
directly fiddles with its managed tables.My current workaround for this is
periods
extension is installed in the target databasepg_dump
as described aboveperiods
extension from the restore:pg_restore --format=custom --list dump.psql | grep -Ev 'EXTENSION - (periods|btree_gist) > dump.use-list
periods
's event-triggers:pg_restore --format=custom --single-transaction --clean --if-exists --use-list=dump.use-list -d my_target_database dump.psql
Is there any other recommended way to dumping and restoring a database with
periods
?A couple of notes:
periods
employing tables all at once -, as the dumped & restored tables inperiods
's schema (also calledperiods
by default) contain meta-data for allperiods
employing tables.btree_gist
needs to be excluded from the use-list too, as it's a dependency ofperiods
and thus can't be dropped and recreated during restorepg_dump
currently only supports including named extensions (-e
argument) but doesn't support excluding named extensions, which makes the use of use-lists necessaryThe text was updated successfully, but these errors were encountered: