2 # ============LICENSE_START=======================================================
3 # Copyright (C) 2021-2022 Nordix Foundation.
4 # ================================================================================
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # SPDX-License-Identifier: Apache-2.0
18 # ============LICENSE_END=========================================================
21 echo "args: schema-name" >&2
26 export POLICY_HOME=/opt/app/policy
27 export operation=upgrade
31 # Create schema directory for upgrade
32 mkdir -p $POLICY_HOME/etc/db/migration/${SCHEMA}/${SCRIPT_DIRECTORY}/
33 # Remove any files from previous operations
34 rm -rf $POLICY_HOME/etc/db/migration/${SCHEMA}/${SCRIPT_DIRECTORY}/* 2>/dev/null
35 # Copy files to upgrade directories
36 cd /home/policy/${SCRIPT_DIRECTORY} && find . -type f -not -path '*/downgrade/*' -not -path '*/downgrade' -print0 \
37 | cpio --null -pud $POLICY_HOME/etc/db/migration/${SCHEMA}/${SCRIPT_DIRECTORY}/
39 releases=$(find $POLICY_HOME/etc/db/migration/${SCHEMA}/${SCRIPT_DIRECTORY}/*/upgrade -type d | sort -u | rev | cut -f2 -d/ | rev)
40 for release in $releases
42 echo "Preparing $operation release version: $release"