From 7d078c2c62c77bc81ba2804a1b36e01bc4d0ad03 Mon Sep 17 00:00:00 2001 From: Wolfgang Kaltz Date: Wed, 26 Jun 2019 13:05:18 +0200 Subject: [PATCH 1/4] improvement suggestions --- doc/integrator/database.rst | 52 ++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/doc/integrator/database.rst b/doc/integrator/database.rst index 30f7582199..813c682deb 100644 --- a/doc/integrator/database.rst +++ b/doc/integrator/database.rst @@ -1,46 +1,46 @@ .. _integrator_database: -======== Database ======== -To be able to do a rollback the integration and the production data should be in the same database, -but the schema will be different. +Update lifecycle +---------------- +The recommended setup is to have integration and production data on the same database, using +separate schemas. This setup allows for simpler switches between integration and production. -For the static schema will have one for the integration and one for the production environments, e.-g.: +The recommended setup for the ``static`` schema is to have exactly one schema for integration +and one for the production, e.-g.: ``integration_static`` for the integration environment, and ``production_static`` for the production environment. -For the main schema will have one for each version of the application. We will have the following livecycle: - -Current version: -integration and production => ``main_2017`` - -Start an upgrade (application or admin (layertree)), create an new schema and use it on integration: -integration = ``main_2018``, and production => ``main_2017`` - -Do the changes or the upgrade. - -Publish the new version: -integration and production => ``main_2018`` - -The schema ``main_2017`` still exists to be able to rollback the production. +For the data of the ``main`` schema, we recommend to have one schema for each version of the application. +The following example shows how an update can be performed from a version ``2017`` to a version ``2018``: -To do that we should manage the ``PGSCHEMA`` and the ``DOCKER_PGSCHEMA_STATIC`` variable in your -makefiles. +* Starting point is that the current version is the same on integration and production => ``main_2017`` +* When starting the changes, such as an application change and/or administration settings, + create a new schema ``main_2018`` and use it on integration. Now, integration uses ``main_2018``, + while production still uses ``main_2017``. +* Do the changes or the upgrade. +* Publish the new version on production: now, integration and production both use ``main_2018`` +* The schema ``main_2017`` still exists, so if needed, the production can be rolled back to this content. -The ``PGSCHEMA`` should be set in the ``Makefile`` and the ``DOCKER_PGSCHEMA_STATIC`` for the -production should be set in a specific makefile for the production e.-g. ``production.mk``. +To be able to proceed like this, the variables ``PGSCHEMA`` and the ``DOCKER_PGSCHEMA_STATIC`` +should be managed in your makefiles: -And the line `PGSCHEMA=${docker_schema}` should be removed from your `.env.mako` file. +* the ``PGSCHEMA`` variable should be set in the ``Makefile``. +* the ``DOCKER_PGSCHEMA_STATIC`` variable for the production should be set in a specific makefile for the production e.-g. ``production.mk``. +* the line ``PGSCHEMA=${docker_schema}`` should be removed from your ``.env.mako`` file. -To copy the schema, we provide a Postgres function, to create it use: +Copying a schema +---------------- +To copy a schema, `c2cgeoportal` provides a Postgres function called `clone_schema`. +If you have not created it in your database, use to following command to create this function: .. prompt:: bash - docker-compose exec geoporal psql --file=scripts/CONST_clone_schema.sql + docker-compose exec geoportal psql --file=scripts/CONST_clone_schema.sql -To use it: +To use the function, connect to your database and perform the following statement: .. code:: sql From b316efe9d590e5b13d4960c723830ded968ff58a Mon Sep 17 00:00:00 2001 From: Wolfgang Kaltz Date: Wed, 26 Jun 2019 13:58:41 +0200 Subject: [PATCH 2/4] Update doc/integrator/database.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Stéphane Brunner --- doc/integrator/database.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/integrator/database.rst b/doc/integrator/database.rst index 813c682deb..fecdff00ac 100644 --- a/doc/integrator/database.rst +++ b/doc/integrator/database.rst @@ -38,7 +38,8 @@ If you have not created it in your database, use to following command to create .. prompt:: bash - docker-compose exec geoportal psql --file=scripts/CONST_clone_schema.sql + docker-compose exec geoportal psql \ + --file=scripts/CONST_clone_schema.sql To use the function, connect to your database and perform the following statement: From dbeb11172b5f07aac629f04116b1a9bba2dae5fe Mon Sep 17 00:00:00 2001 From: Wolfgang Kaltz Date: Wed, 26 Jun 2019 13:59:03 +0200 Subject: [PATCH 3/4] Update doc/integrator/database.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Stéphane Brunner --- doc/integrator/database.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/integrator/database.rst b/doc/integrator/database.rst index fecdff00ac..e3720fd1ba 100644 --- a/doc/integrator/database.rst +++ b/doc/integrator/database.rst @@ -44,5 +44,7 @@ If you have not created it in your database, use to following command to create To use the function, connect to your database and perform the following statement: .. code:: sql - + SELECT clone_schema( + '', + '', TRUE); SELECT clone_schema('', '', TRUE); From 6d520df63de25b370feda58e98d1591fa9a541c2 Mon Sep 17 00:00:00 2001 From: Wolfgang Kaltz Date: Wed, 26 Jun 2019 14:01:29 +0200 Subject: [PATCH 4/4] formattting --- doc/integrator/database.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/integrator/database.rst b/doc/integrator/database.rst index e3720fd1ba..618243b11d 100644 --- a/doc/integrator/database.rst +++ b/doc/integrator/database.rst @@ -44,7 +44,7 @@ If you have not created it in your database, use to following command to create To use the function, connect to your database and perform the following statement: .. code:: sql + SELECT clone_schema( '', '', TRUE); - SELECT clone_schema('', '', TRUE);