From 3550a3713bd3fa310aade3895787c4c0eef2f28a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Wed, 26 Jun 2019 09:33:44 +0200 Subject: [PATCH] Remove layerv1 artifacts --- commons/alembic.ini | 6 +- .../main/56dc90838d90_fix_removing_layerv1.py | 59 +++++++++++++++++++ doc/developer/server_side.rst.tmpl | 6 +- .../create/docker-compose-lib.yaml_tmpl | 1 + 4 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 commons/c2cgeoportal_commons/alembic/main/56dc90838d90_fix_removing_layerv1.py diff --git a/commons/alembic.ini b/commons/alembic.ini index ef21ba03a9..612932c912 100644 --- a/commons/alembic.ini +++ b/commons/alembic.ini @@ -1,15 +1,15 @@ [DEFAULT] app.cfg = %(here)s/alembic.yaml -script_location = /opt/alembic +script_location = c2cgeoportal_commons:alembic version_table = alembic_version [main] type = main -version_locations = /opt/alembic/main/ +version_locations = c2cgeoportal_commons:alembic/main/ [static] type = static -version_locations = /opt/alembic/static/ +version_locations = c2cgeoportal_commons:alembic/static/ # Logging configuration [loggers] diff --git a/commons/c2cgeoportal_commons/alembic/main/56dc90838d90_fix_removing_layerv1.py b/commons/c2cgeoportal_commons/alembic/main/56dc90838d90_fix_removing_layerv1.py new file mode 100644 index 0000000000..1fa83c710c --- /dev/null +++ b/commons/c2cgeoportal_commons/alembic/main/56dc90838d90_fix_removing_layerv1.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2019, Camptocamp SA +# All rights reserved. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: + +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. + +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# The views and conclusions contained in the software and documentation are those +# of the authors and should not be interpreted as representing official policies, +# either expressed or implied, of the FreeBSD Project. + +"""Fix removing layerv1 + +Revision ID: 56dc90838d90 +Revises: 1de20166b274 +Create Date: 2019-06-25 17:56:25.991417 +""" + +from alembic import op +from c2c.template.config import config + +# revision identifiers, used by Alembic. +revision = '56dc90838d90' +down_revision = '1de20166b274' +branch_labels = None +depends_on = None + + +def upgrade(): + schema = config['schema'] + + op.execute(( + "DELETE from {schema}.layer_restrictionarea WHERE layer_id IN (" + "SELECT id from {schema}.treeitem WHERE type = 'layerv1'" + ");" + ).format(schema=schema)) + op.execute("DELETE from {schema}.treeitem WHERE type = 'layerv1';".format(schema=schema)) + + +def downgrade(): + pass diff --git a/doc/developer/server_side.rst.tmpl b/doc/developer/server_side.rst.tmpl index 7f4e17f0ce..ff52822638 100644 --- a/doc/developer/server_side.rst.tmpl +++ b/doc/developer/server_side.rst.tmpl @@ -112,13 +112,13 @@ Add a new script in c2cgeoportal root directory: .. prompt:: bash - docker-compose exec geoportal alembic \ - --config geoportal/tests/functional/alembic.ini \ + python3 -m pip install --user -e commons + alembic --config=commons/alembic.ini \ --name=[main|static] \ revision --message "" This will generate the migration script in -``commons/c2cgeoportal/commons/alembic/[main|static]/xxx_.py``. +``commons/c2cgeoportal_commons/alembic/[main|static]/xxx_.py``. To get the project schema, use: ``schema = context.get_context().config.get_main_option('schema')`` diff --git a/geoportal/c2cgeoportal_geoportal/scaffolds/create/docker-compose-lib.yaml_tmpl b/geoportal/c2cgeoportal_geoportal/scaffolds/create/docker-compose-lib.yaml_tmpl index 19f50698fd..9d191960f1 100644 --- a/geoportal/c2cgeoportal_geoportal/scaffolds/create/docker-compose-lib.yaml_tmpl +++ b/geoportal/c2cgeoportal_geoportal/scaffolds/create/docker-compose-lib.yaml_tmpl @@ -158,6 +158,7 @@ services: alembic: image: ${DOCKER_BASE}-geoportal:${DOCKER_TAG} user: www-data + entrypoint: [] command: - alembic - --name=static