aboutsummaryrefslogtreecommitdiff
path: root/scripts/guix-data-service-create-small-backup
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-03-13 18:37:46 +0000
committerChristopher Baines <mail@cbaines.net>2020-03-13 18:37:46 +0000
commitb64e6b19c22488b11fa2bd70399aed302988343f (patch)
tree6d819df632b1f0ad65e193872edf03b576755b28 /scripts/guix-data-service-create-small-backup
parent24e7df541be727ecbc0041099cf3fc53d070b8c9 (diff)
downloaddata-service-b64e6b19c22488b11fa2bd70399aed302988343f.tar
data-service-b64e6b19c22488b11fa2bd70399aed302988343f.tar.gz
Trim derivation source file tables in the small data dump
Diffstat (limited to 'scripts/guix-data-service-create-small-backup')
-rwxr-xr-xscripts/guix-data-service-create-small-backup30
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/guix-data-service-create-small-backup b/scripts/guix-data-service-create-small-backup
index c5c5678..a5f8cc6 100755
--- a/scripts/guix-data-service-create-small-backup
+++ b/scripts/guix-data-service-create-small-backup
@@ -120,6 +120,28 @@ wait
psql -v ON_ERROR_STOP=1 --echo-queries --no-psqlrc "$URI_FOR_DATABASE" -U guix_data_service <<EOF &
+CREATE UNLOGGED TABLE tmp_derivation_source_files AS
+SELECT *
+FROM derivation_source_files
+WHERE id IN (
+ SELECT derivation_source_file_id
+ FROM tmp_derivation_sources
+);
+
+CREATE UNLOGGED TABLE tmp_derivation_source_file_nars AS
+SELECT *
+FROM derivation_source_file_nars
+WHERE derivation_source_file_id IN (
+ SELECT id FROM tmp_derivation_source_files
+);
+
+TRUNCATE derivation_source_files CASCADE; -- Cascades to derivation_sources
+TRUNCATE derivation_source_file_nars;
+
+EOF
+
+psql -v ON_ERROR_STOP=1 --echo-queries --no-psqlrc "$URI_FOR_DATABASE" -U guix_data_service <<EOF &
+
DELETE FROM guix_revision_lint_warnings WHERE guix_revision_id NOT IN (
SELECT id FROM guix_revisions WHERE commit IN (SELECT commit FROM git_branches)
);
@@ -199,8 +221,14 @@ INSERT INTO derivation_outputs OVERRIDING SYSTEM VALUE
INSERT INTO derivation_inputs
SELECT * FROM tmp_derivation_inputs;
+INSERT INTO derivation_source_files OVERRIDING SYSTEM VALUE
+ SELECT * FROM tmp_derivation_source_files;
+
INSERT INTO derivation_sources
SELECT * FROM tmp_derivation_sources;
+
+INSERT INTO derivation_source_file_nars
+ SELECT * FROM tmp_derivation_source_file_nars;
EOF
psql -v ON_ERROR_STOP=1 --echo-queries --no-psqlrc "$URI_FOR_DATABASE" -U guix_data_service <<EOF
@@ -213,6 +241,8 @@ DROP TABLE tmp_build_status;
DROP TABLE tmp_derivation_outputs;
DROP TABLE tmp_derivation_inputs;
DROP TABLE tmp_derivation_sources;
+DROP TABLE tmp_derivation_source_files;
+DROP TABLE tmp_derivation_source_file_nars;
EOF