From c37aea8ce8c91ac2757a9df2a254c7fde125d794 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Arthur=20Brugi=C3=A8re?= <contact@arthurbrugiere.fr>
Date: Mon, 1 Nov 2021 15:52:34 +0000
Subject: [PATCH] [DOC] Update PostGres command for Multi-Docker migration

---
 docs/admin/migration.rst | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/docs/admin/migration.rst b/docs/admin/migration.rst
index 18f7d0513..9c23c5098 100644
--- a/docs/admin/migration.rst
+++ b/docs/admin/migration.rst
@@ -91,11 +91,22 @@ On the destination server, use rsync to fetch the contents of ``/srv/funwkhale/d
     rsync -a $username@$origin:/srv/funkwhale/.env /srv/funkwhale/
     rsync -a $username@$origin:/srv/funkwhale/db.dump /srv/funkwhale/
 
-Restore the database dump:
+Initialize the Postgres container with the funkwhale database and its user. For easier, we create a db init dump file than we import in the postgres container:
 
 .. code-block:: shell
 
-    docker exec -i funkwhale_postgres_1 psql -U postgres -d postgres < db.dump
+    echo "CREATE DATABASE "funkwhale"
+  WITH ENCODING 'utf8';
+  CREATE USER funkwhale;
+  GRANT ALL PRIVILEGES ON DATABASE funkwhale TO funkwhale;" > init.dump
+
+    docker exec -i funkwhale_postgres_1 psql -U postgres -d postgres < "init.dump"
+
+After that, we can restore the database dump:
+
+.. code-block:: shell
+
+    docker exec -i funkwhale_postgres_1 psql -U postgres -d postgres < "db.dump"
 
 Once the database has been restored, run the migrations following the docker installation guide. 
 
-- 
GitLab