fix(init): ch password issue

Signed-off-by: rjshrjndrn <rjshrjndrn@gmail.com>
This commit is contained in:
rjshrjndrn 2023-02-27 16:24:17 +01:00 committed by Taha Yassine Kraiem
parent 8765cc7d89
commit f4e0d509ec

View file

@ -4,6 +4,10 @@ set -ex
clickhousedir=/opt/openreplay/openreplay/scripts/schema/db/init_dbs/clickhouse
[[ "${CH_PASSWORD}" == "" ]] || {
CH_PASSWORD="--password $CH_PASSWORD"
}
function migrate() {
echo "Starting clickhouse migration"
IFS=',' read -r -a migration_versions <<< "$1"
@ -11,7 +15,7 @@ function migrate() {
echo "Migrating clickhouse version $version"
# For now, we can ignore the clickhouse db inject errors.
# TODO: Better error handling in script
clickhouse-client -h ${CH_HOST} --port ${CH_PORT} --user ${CH_USERNAME} --password ${CH_PASSWORD} --multiquery < ${clickhousedir}/${version}/${version}.sql || true
clickhouse-client -h ${CH_HOST} --port ${CH_PORT} --user ${CH_USERNAME} ${CH_PASSWORD} --multiquery < ${clickhousedir}/${version}/${version}.sql || true
done
}
@ -19,7 +23,7 @@ function init() {
echo "Initializing clickhouse"
for file in `ls ${clickhousedir}/create/*.sql`; do
echo "Injecting $file"
clickhouse-client -h ${CH_HOST} --user ${CH_USERNAME} --password ${CH_PASSWORD} --port ${CH_PORT} --multiquery < $file || true
clickhouse-client -h ${CH_HOST} --user ${CH_USERNAME} ${CH_PASSWORD} --port ${CH_PORT} --multiquery < $file || true
done
}