diff options
| author | Carlos Konstanski <ckonstanski@pippiandcarlos.com> | 2017-10-13 11:48:51 -0600 |
|---|---|---|
| committer | Carlos Konstanski <ckonstanski@pippiandcarlos.com> | 2017-10-13 11:48:51 -0600 |
| commit | 02ceb4984bc3277e40bb6c70eed3bcbab7cf84f3 (patch) | |
| tree | 0b4f6246dc0a22bd90855b9b9bc6fb868874dc27 /salt/openbook | |
| parent | 5bc86cfe70376371a4305bc2dc067b0f426a5ad7 (diff) | |
update database schema script
Diffstat (limited to 'salt/openbook')
| -rw-r--r-- | salt/openbook/database/files/update-openbook-schema.sh | 37 |
1 files changed, 37 insertions, 0 deletions
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 <<EOF >>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 |
