Enable bash strict mode in all shell scripts to catch errors early: - set -e: Exit immediately if a command exits with non-zero status - set -u: Treat unset variables as an error - set -o pipefail: Return value of a pipeline is the status of the last command to exit with non-zero status This prevents silent failures and makes debugging easier by failing fast when something goes wrong instead of continuing with potentially corrupted state.
33 lines
1.1 KiB
Bash
Executable File
33 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
echo "Post migration to 17.0..."
|
|
|
|
# Execute SQL post-migration commands
|
|
POST_MIGRATE_SQL=$(cat <<'EOF'
|
|
DO $$
|
|
DECLARE
|
|
plan_id INTEGER;
|
|
BEGIN
|
|
-- Check if the 'Projects' analytic plan exists
|
|
SELECT id INTO plan_id FROM account_analytic_plan WHERE complete_name = 'migration_PROJECTS' LIMIT 1;
|
|
|
|
-- If it does exist, delete it
|
|
IF plan_id IS NOT NULL THEN
|
|
DELETE FROM account_analytic_plan WHERE complete_name = 'migration_PROJECTS';
|
|
SELECT id INTO plan_id FROM account_analytic_plan WHERE complete_name = 'Projects' LIMIT 1;
|
|
-- Delete existing system parameter (if any)
|
|
DELETE FROM ir_config_parameter WHERE key = 'analytic.project_plan';
|
|
-- Insert the system parameter with the correct plan ID
|
|
INSERT INTO ir_config_parameter (key, value, create_date, write_date)
|
|
VALUES ('analytic.project_plan', plan_id::text, now(), now());
|
|
END IF;
|
|
END $$;
|
|
EOF
|
|
)
|
|
echo "SQL command = $POST_MIGRATE_SQL"
|
|
query_postgres_container "$POST_MIGRATE_SQL" ou17 || exit 1
|
|
|
|
|
|
#compose --debug run ou17 -u base --stop-after-init --no-http
|