Skip to content

Commit

Permalink
fix: docker snapshot restoration
Browse files Browse the repository at this point in the history
 * Upgrade postgres libraries @ 14
 * Avoid dropping database in restore script
  • Loading branch information
sgillespie committed Jul 17, 2024
1 parent d21895f commit f6a46d9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
# Database tests
let
postgresTest = {
build-tools = [ pkgs.pkgsBuildHost.postgresql_12 ];
build-tools = [ pkgs.pkgsBuildHost.postgresql_14 ];
inherit preCheck;
inherit postCheck;
};
Expand Down
4 changes: 2 additions & 2 deletions nix/docker.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
, bashInteractive, cacert, cardano-cli, cardano-db-sync, cardano-db-tool
, cardano-smash-server, coreutils, curl, findutils, getconf, glibcLocales
, gnused, gnutar, gzip, jq, iana-etc, iproute, iputils, lib, libidn, libpqxx
, postgresql, socat, utillinux
, postgresql_14, socat, utillinux
}:

let
Expand Down Expand Up @@ -46,7 +46,7 @@ let
iputils # Useful utilities for Linux networking
libidn # Library for internationalized domain names
libpqxx # A C++ library to access PostgreSQL databases
postgresql # A powerful, open source object-relational database system
postgresql_14 # A powerful, open source object-relational database system
socat # Utility for bidirectional data transfer
utillinux # System utilities for Linux
cardano-cli # tool for interacting with cardano-node
Expand Down
2 changes: 1 addition & 1 deletion nix/nixos/tests/services-basic-test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ with pkgs;
systemd.services.cardano-db-sync.serviceConfig.SupplementaryGroups = "cardano-node";
services.postgresql = {
enable = true;
package = postgresql_12;
package = postgresql_14;
enableTCPIP = false;
ensureDatabases = [ "${config.services.cardano-db-sync.postgres.database}" ];
initialScript = builtins.toFile "enable-pgcrypto.sql" ''
Expand Down
3 changes: 1 addition & 2 deletions scripts/postgresql-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ function restore_snapshot {
lstate_gz_file=$(find "${tmp_dir}/" -iname "*.lstate.gz")
lstate_file=$(basename "${lstate_gz_file}" | sed 's/.gz$//')
gunzip --to-stdout "${lstate_gz_file}" > "$2/${lstate_file}"
drop_db

# Important: specify --schema=public below to skip over `create schema public`
# statement generated by pg_dump
Expand All @@ -202,7 +201,7 @@ function restore_snapshot {
--jobs="${numcores}" \
--format=directory \
--dbname="${PGDATABASE}" \
--no-owner \
--no-owner \
--exit-on-error \
"${tmp_dir}/db/"
else
Expand Down

0 comments on commit f6a46d9

Please sign in to comment.