From cad6e0dc203d5d852f8e57938733d12728bd8109 Mon Sep 17 00:00:00 2001 From: Aron Novak Date: Tue, 27 Feb 2024 21:19:15 +0100 Subject: [PATCH] Allow sql dumping via the Makefile (#1916) * make it possible to create a full dump of the instance, tables + data together * Update lib/IHP/Makefile.dist Co-authored-by: Amitai Burstein * portable dump * dump * Update Guide/database.markdown --------- Co-authored-by: Amitai Burstein --- Guide/database.markdown | 4 ++++ lib/IHP/Makefile.dist | 3 +++ 2 files changed, 7 insertions(+) diff --git a/Guide/database.markdown b/Guide/database.markdown index ad11bdf02..954c42328 100644 --- a/Guide/database.markdown +++ b/Guide/database.markdown @@ -92,6 +92,10 @@ You can also update the database while keeping its contents. When dumping the database into the `Fixtures.sql` first and then rebuilding the database with the dump, the contents will be kept when changing the schema. +### Transferring/Backing Up DB + +To have the full database dumped in a portable manner, you can do `make sql_dump > /tmp/my_app.sql`, which will generate a full SQL database dump, without owner or ACL information. + ## Haskell Bindings ### Model Context diff --git a/lib/IHP/Makefile.dist b/lib/IHP/Makefile.dist index 5358d4cb4..6a3ca2890 100644 --- a/lib/IHP/Makefile.dist +++ b/lib/IHP/Makefile.dist @@ -123,6 +123,9 @@ dumpdb: dump_db ## Saves the current database state into the Fixtures.sql dump_db: ## Saves the current database state into the Fixtures.sql pg_dump -a --inserts --column-inserts --disable-triggers -h $$PWD/build/db app | sed -e '/^--/d' > Application/Fixtures.sql +sql_dump: ## Saves the current database state, so it can dumped into an SQL file `make sql_dump > dump.sql` + @pg_dump --no-owner --no-acl -h $$PWD/build/db app | sed -e '/^--/d' + build/Generated/Types.hs: Application/Schema.sql ## Rebuilds generated types mkdir -p build/Generated build-generated-code