- POLICY-3622Getting issue details... STATUS
Prerequisites
Check number of files in each release
cd /git/docker/policy-db-migrator/src/main/docker/config/policyadmin/sql$
ls 0800/upgrade/*.sql | wc -l
96
ls 0900/upgrade/*.sql | wc -l
13
ls 0800/downgrade/*.sql | wc -l
96
ls 0900/downgrade/*.sql | wc -l
13
Upgrade scripts:
/opt/app/policy/bin/prepare_upgrade.sh policyadmin
/opt/app/policy/bin/db-migrator -s policyadmin -o upgrade
Downgrade scripts:
/opt/app/policy/bin/prepare_downgrade.sh policyadmin
/opt/app/policy/bin/db-migrator -s policyadmin -o downgrade -f 0900 -t 0800
Db migrator initialization script:
To run scripts update /oom/kubernetes/policy/resources/config/db_migrator_policy_init.sh with the appropriate calls.
Please ensure the policy version you are deploying is in line with the db migrator schema version.
Every time you modify db_migrator_policy_init.sh you will have to undeploy, make and redeploy before updates are run.
1. Fresh Install
Number of files run = 109
Tables in policyadmin = 75
Records in policyadmin_schema_changelog = 109
Version in schema_versions: 0900
2. Downgrade to Honolulu (0800)
Modify db_migrator_policy_init.sh - Remove any lines referencing upgrade and add the 2 lines under "Downgrade scripts"
Number of files run = 13
Tables in policyadmin = 73
Records in policyadmin_schema_changelog = 109+13=122
Version in schema_versions: 0800
3. Upgrade to Istanbul (0900)
Modify db_migrator_policy_init.sh - Remove any lines referencing downgrade and add the 2 lines under "Upgrade scripts"
Number of files run = 13
Tables in policyadmin = 75
Records in policyadmin_schema_changelog = 122+13=135
Version in schema_versions: 0900
4. Upgrade to Istanbul (0900) without any information in the migration schema
Ensure you are on release 0800. (This may require running a downgrade before starting the test)
Drop db-migrator tables in migration schema: DROP TABLE schema_versions; DROP TABLE policyadmin_schema_changelog;
Modify db_migrator_policy_init.sh - Remove any lines referencing downgrade and add the 2 lines under "Upgrade scripts"
Number of files run = 13
Tables in policyadmin = 75
Records in policyadmin_schema_changelog = 13 (previous records removed when table was dropped)
Version in schema_versions: 0900
5. Upgrade to Istanbul (0900) after failed downgrade
Ensure you are on release 0900.
Rename pdpstatistics table in policyadmin schema: RENAME TABLE pdpstatistics to backup_pdpstatistics;
Modify db_migrator_policy_init.sh - Remove any lines referencing upgrade and add the 2 lines under "Downgrade scripts"
This should result in an error (last row in policyadmin_schema_changelog will have a success value of 0)
Rename backup_pdpstatistic table in policyadminschema: RENAME TABLE backup_pdpstatistic to pdpstatistics;
Modify db_migrator_policy_init.sh - Remove any lines referencing downgrade and add the 2 lines under "Upgrade scripts"
Make + Re-run/redeploy
Number of files run = 11
Tables in policyadmin = 75
Records in policyadmin_schema_changelog = 24
Version in schema_versions: 0900
6. Downgrade to Honolulu (0800) after failed downgrade
Ensure you are on release 0900.
Rename pdpstatistics table in policyadmin schema: RENAME TABLE pdpstatistics to backup_pdpstatistics;
Modify db_migrator_policy_init.sh - Remove any lines referencing upgrade and add the 2 lines under "Downgrade scripts"
This should result in an error (last row in policyadmin_schema_changelog will have a success value of 0)
Rename backup_pdpstatistic table in policyadminschema: RENAME TABLE backup_pdpstatistic to pdpstatistics;
Modify db_migrator_policy_init.sh - Remove any lines referencing downgrade and add the 2 lines under "Upgrade scripts"
Re-run/redeploy
Number of files run = 12
Tables in policyadmin = 73
Records in policyadmin_schema_changelog = 36
Version in schema_versions: 0800
Test Results
kubectl logs: db_migrator_kubectl_logs.xlsx
Resources
Insert statements for pdpstatistics and jpapdpstatistics_enginestats: