[NEW] add first version of 0k Odoo Upgrade scripts

This commit is contained in:
Stéphan Sainléger
2024-11-25 15:35:05 +01:00
parent 950c319040
commit 076a7bb3eb
19 changed files with 714 additions and 0 deletions

0
13.0/post_upgrade.sh Normal file
View File

45
13.0/pre_upgrade.sh Normal file
View File

@@ -0,0 +1,45 @@
#!/bin/bash
DB_CONTAINER_NAME="lokavaluto_postgres_1"
# Function to launch an SQL request to the postgres container
query_postgres_container(){
local query="$1"
if [ -z "$query" ]; then
return 0
fi
local result
if ! result=$(docker exec -u 70 "$DB_CONTAINER_NAME" psql -d ou13 -t -A -c "$query" 2>&1); then
printf "Failed to execute SQL query: %s\n" "$query" >&2
printf "Error: %s\n" "$result" >&2
exit 1
fi
# Remove leading/trailing whitespace from result
result=$(echo "$result" | xargs)
echo "$result"
}
echo "Prepare migration to 13.0..."
# Copy database
docker exec -u 70 "$DB_CONTAINER_NAME" pgm cp -f ou12 ou13@ou13
# Execute SQL pre-migration commands
PRE_MIGRATE_SQL=$(cat <<'EOF'
/* Add analytic_policy column as openupgrade script is waiting for it whereas it doesn't existe since v12. */
ALTER TABLE public.account_account_type ADD analytic_policy varchar NULL;
/* The model in missing on some website_sale data */
UPDATE ir_model_data SET model = 'ir.ui.view' WHERE module = 'website_sale' AND name = 'recommended_products';
UPDATE ir_model_data SET model = 'ir.ui.view' WHERE module = 'website_sale' AND name = 'product_comment';
EOF
)
query_postgres_container "$PRE_MIGRATE_SQL"
# Copy filestores
rm -rf /srv/datastore/data/ou13/var/lib/odoo/filestore/ou13/* || exit 1
mkdir /srv/datastore/data/ou13/var/lib/odoo/filestore/ou13/* || exit 1
cp -a /srv/datastore/data/ou12/var/lib/odoo/filestore/ou12/* /srv/datastore/data/ou13/var/lib/odoo/filestore/ou13/ || exit 1
echo "Ready for migration to 13.0!"

3
13.0/upgrade.sh Normal file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
compose -f ../compose.yml run -p 8013:8069 ou13 --config=/opt/odoo/auto/odoo.conf --stop-after-init -u all --workers 0 --log-level=warn --max-cron-threads=0 --limit-time-real=10000 --database=ou13