From 02ceb4984bc3277e40bb6c70eed3bcbab7cf84f3 Mon Sep 17 00:00:00 2001 From: Carlos Konstanski Date: Fri, 13 Oct 2017 11:48:51 -0600 Subject: update database schema script --- .../database/files/update-openbook-schema.sh | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 salt/openbook/database/files/update-openbook-schema.sh (limited to 'salt') diff --git a/salt/openbook/database/files/update-openbook-schema.sh b/salt/openbook/database/files/update-openbook-schema.sh new file mode 100644 index 0000000..d5c5ed9 --- /dev/null +++ b/salt/openbook/database/files/update-openbook-schema.sh @@ -0,0 +1,37 @@ +#!/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 -- cgit v1.3