From e19c05c812542f079e7916fdb8b91b1763d81e87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phan=20Sainl=C3=A9ger?= Date: Mon, 16 Dec 2024 12:30:43 +0100 Subject: [PATCH] imp: remove useless final model db name attribute --- README.md | 7 +++---- prepare_db.sh | 2 +- upgrade.sh | 28 +++++++++++++++------------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 70a921c..0214942 100644 --- a/README.md +++ b/README.md @@ -19,14 +19,13 @@ ### Local Migration process - [ ] launch the origin database `ORIGIN_DATABASE_NAME` with original version of Odoo, with odoo service `ORIGIN_SERVICE` -- [ ] ensure you have a virgin database of the final version already in your postgres service (`MODEL_FINAL_DATABASE_NAME`) - [ ] launch the following command: ``` bash -./upgrade.sh {ORIGIN_VERSION} {DESTINATION_VERSION} {ORIGIN_DATABASE_NAME} {ORIGIN_SERVICE} {MODEL_FINAL_DATABASE_NAME} +./upgrade.sh {ORIGIN_VERSION} {DESTINATION_VERSION} {ORIGIN_DATABASE_NAME} {ORIGIN_SERVICE} ``` -ex: ./upgrade.sh 14 16 elabore_20241208 odoo14 ou16 +ex: ./upgrade.sh 14 16 elabore_20241208 odoo14 ### Deploy migrated base @@ -41,7 +40,7 @@ The migration script will manage the uninstall of Odoo add-ons: - add-ons we want to uninstall, whatever the reasons - add-ons to uninstall because they do not exist in the final Odoo docker image -At the beginning of the process, the script compare the list of add-ons installed in the origin database, and the list of add-ons available in the `MODEL_FINAL_DATABASE`. +At the beginning of the process, the script compare the list of add-ons installed in the origin database, and the list of add-ons available in the finlal Odoo docker image. The whole list of add-ons to uninstall is displayed, and needs a confirmation before starting the migration. diff --git a/prepare_db.sh b/prepare_db.sh index 14bb644..f54d6e1 100755 --- a/prepare_db.sh +++ b/prepare_db.sh @@ -77,7 +77,7 @@ SQL_404_ADDONS_LIST=" FROM ir_module_module module_origin LEFT JOIN ( SELECT * - FROM dblink('dbname=$DB_FINALE_MODEL','SELECT name, shortdesc, author FROM ir_module_module') + FROM dblink('dbname=$FINALE_DB_NAME','SELECT name, shortdesc, author FROM ir_module_module') AS tb2(name text, shortdesc text, author text) ) AS module_dest ON module_dest.name = module_origin.name diff --git a/upgrade.sh b/upgrade.sh index cdc8b8d..c5286e4 100755 --- a/upgrade.sh +++ b/upgrade.sh @@ -9,13 +9,11 @@ FINAL_VERSION="$2" # "16" for version 16.0 # Path to the database to migrate. Must be a .zip file with the following syntax: {DATABASE_NAME}.zip ORIGIN_DB_NAME="$3" ORIGIN_SERVICE_NAME="$4" -FINALE_DB_MODEL_NAME="$5" #To check the add-ons available in the finale version - # Get origin database name COPY_DB_NAME="ou${ORIGIN_VERSION}" # Define finale database name -FINALE_DB_NAME="ou${FINAL_VERSION}" +export FINALE_DB_NAME="ou${FINAL_VERSION}" # Define finale odoo service name FINALE_SERVICE_NAME="${FINALE_DB_NAME}" @@ -31,7 +29,6 @@ echo "Origin version .......... $ORIGIN_VERSION" echo "Final version ........... $FINAL_VERSION" echo "Origin DB name ........... $ORIGIN_DB_NAME" echo "Origin service name ..... $ORIGIN_SERVICE_NAME" -echo "Finale DB model name .... $FINALE_DB_MODEL_NAME" echo " ===== COMPUTED GLOBALE VARIABLES =====" @@ -104,15 +101,6 @@ else exit 1 fi -# Check final version database model is in the local postgres -DB_EXISTS=$(docker exec -it -u 70 $POSTGRES_SERVICE_NAME psql -tc "SELECT 1 FROM pg_database WHERE datname = '$FINALE_DB_MODEL_NAME'" | tr -d '[:space:]') -if [ "$DB_EXISTS" ]; then - echo "UPGRADE: Database '$FINALE_DB_MODEL_NAME' found." -else - echo "ERROR: Database '$FINALE_DB_MODEL_NAME' not found in the local postgress service. Please add it and restart the upgrade process." - exit 1 -fi - # Check that the origin filestore exist REPERTOIRE="/srv/datastore/data/${ORIGIN_SERVICE_NAME}/var/lib/odoo/filestore/${ORIGIN_DB_NAME}" if [ -d $REPERTOIRE ]; then @@ -122,6 +110,20 @@ else exit 1 fi +####################################### +# LAUNCH VIRGIN ODOO IN FINAL VERSION # +####################################### + +compose --debug run "$FINALE_SERVICE_NAME" --stop-after-init --no-http + +# Check final version database model is in the local postgres +DB_EXISTS=$(docker exec -it -u 70 $POSTGRES_SERVICE_NAME psql -tc "SELECT 1 FROM pg_database WHERE datname = '$FINALE_SERVICE_NAME'" | tr -d '[:space:]') +if [ "$DB_EXISTS" ]; then + echo "UPGRADE: Database '$FINALE_SERVICE_NAME' found." +else + echo "ERROR: Database '$FINALE_SARVICE_NAME' not found in the local postgress service." + exit 1 +fi ############################