#!/bin/bash pushd /root/update-openbook-schema >/dev/null rm -rf openbook-v4-ci git clone git@github.com:Talligent/openbook-v4-ci.git pushd openbook-v4-ci/salt/openbook/database/files >/dev/null mysqldump --skip-add-drop-table --skip-comments --add-locks --create-options --disable-keys --extended-insert --lock-tables --quick --set-charset --no-data --single-transaction -h 127.0.0.1 --databases openbook openbook_jobs openbook_workflow > create_openbook_schemas.sql for db in openbook openbook_jobs openbook_workflow; do sed -e "s|USE \`${db}\`;|GRANT ALL PRIVILEGES ON ${db}.* TO ${db}@'%' IDENTIFIED BY '{% raw %}{{ openbook_database_password }}{% endraw %}';\nGRANT ALL PRIVILEGES ON ${db}.* TO ${db}@localhost IDENTIFIED BY '{% raw %}{{ openbook_database_password }}{% endraw %}';\n\nUSE \`${db}\`;|g" -i create_openbook_schemas.sql done sed --posix -r 's|(^.*PARTITION BY RANGE.*\))|\1;|g' -i create_openbook_schemas.sql sed -e 's|^.*PARTITION.*VALUES.*ENGINE = InnoDB.*$||g' -i create_openbook_schemas.sql cat <>create_openbook_schemas.sql use openbook; CALL p_preallocate_partitions('t_metric_values', 'metric_datetime', CURDATE(), 31); CALL p_preallocate_partitions('t_metric_aggregate_resource_hourly', 'aggregate_datetime', CURDATE(), 31); CALL p_preallocate_partitions('t_metric_aggregate_tenant_hourly', 'aggregate_datetime', CURDATE(), 31); CALL p_preallocate_partitions('t_metric_aggregate_customer_hourly', 'aggregate_datetime', CURDATE(), 31); CALL p_preallocate_partitions('t_metric_aggregate_resource_daily', 'aggregate_datetime', CURDATE(), 31); CALL p_preallocate_partitions('t_metric_aggregate_tenant_daily', 'aggregate_datetime', CURDATE(), 31); CALL p_preallocate_partitions('t_metric_aggregate_customer_daily', 'aggregate_datetime', CURDATE(), 31); EOF git add -A git commit -a -m "update create_databases_schama.sql $(date)" git push popd >/dev/null popd >/dev/null exit 0