Skip to content

Commit

Permalink
Remove unused shell version ClickHouse data migration code
Browse files Browse the repository at this point in the history
Signed-off-by: Yanjun Zhou <zhouya@vmware.com>
  • Loading branch information
yanjunz97 committed Jan 27, 2023
1 parent 41c2424 commit fcbd0b6
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 49 deletions.
15 changes: 0 additions & 15 deletions build/charts/theia/provisioning/datasources/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,5 @@ set -e
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

source $THIS_DIR/create_table.sh

# This function is kept to be compatible with version below v0.3.0
function setDataVersion {
tables=$(clickhouse client -h 127.0.0.1 -q "SHOW TABLES")
if [[ $tables == *"migrate_version"* ]]; then
clickhouse client -h 127.0.0.1 -q "ALTER TABLE migrate_version DELETE WHERE version!=''"
else
clickhouse client -h 127.0.0.1 -q "CREATE TABLE migrate_version (version String) engine=MergeTree ORDER BY version"
fi
clickhouse client -h 127.0.0.1 -q "INSERT INTO migrate_version (*) VALUES ('{{ .Chart.Version }}')"
echo "=== Set data schema version to {{ .Chart.Version }} ==="
}

../clickhouse-schema-management
createTable
setDataVersion

This file was deleted.

4 changes: 0 additions & 4 deletions build/charts/theia/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@
- key: {{ regexReplaceAll "(.*)/" $path "" }}
path: {{ regexReplaceAll "(.*)/" $path "" }}
{{- end }}
{{- range $path, $_ := $Files.Glob "provisioning/datasources/migrators/downgrade/*" }}
- key: {{ regexReplaceAll "(.*)/" $path "" }}
path: migrators/downgrade/{{ regexReplaceAll "(.*)/" $path "" }}
{{- end }}
{{- range $path, $_ := $Files.Glob "provisioning/datasources/migrators/*.sql" }}
- key: {{ regexReplaceAll "(.*)/" $path "" }}
path: migrators/{{ regexReplaceAll "(.*)/" $path "" }}
Expand Down
1 change: 0 additions & 1 deletion build/charts/theia/templates/clickhouse/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ metadata:
namespace: {{ .Release.Namespace }}
data:
{{ tpl (.Files.Glob "provisioning/datasources/*.sh").AsConfig . | indent 2 }}
{{ tpl (.Files.Glob "provisioning/datasources/migrators/downgrade/*").AsConfig . | indent 2 }}
{{ (.Files.Glob "provisioning/datasources/migrators/*.sql").AsConfig | indent 2 }}
25 changes: 1 addition & 24 deletions build/yamls/flow-visibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ subjects:
---
apiVersion: v1
data:
0-3-0_0-2-0.sql: |
--Alter table to drop new columns
ALTER TABLE flows
DROP clusterUUID String;
ALTER TABLE flows_local
DROP clusterUUID String;
000001_0-1-0.down.sql: ""
000001_0-1-0.up.sql: |
--Create a table to store records
Expand Down Expand Up @@ -482,7 +476,7 @@ data:
engine=Distributed('{cluster}', default, recommendations_local, rand());
EOSQL
}
init.sh: |+
init.sh: |
#!/usr/bin/env bash
# Copyright 2022 Antrea Authors.
Expand All @@ -504,23 +498,8 @@ data:
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $THIS_DIR/create_table.sh
# This function is kept to be compatible with version below v0.3.0
function setDataVersion {
tables=$(clickhouse client -h 127.0.0.1 -q "SHOW TABLES")
if [[ $tables == *"migrate_version"* ]]; then
clickhouse client -h 127.0.0.1 -q "ALTER TABLE migrate_version DELETE WHERE version!=''"
else
clickhouse client -h 127.0.0.1 -q "CREATE TABLE migrate_version (version String) engine=MergeTree ORDER BY version"
fi
clickhouse client -h 127.0.0.1 -q "INSERT INTO migrate_version (*) VALUES ('0.5.0')"
echo "=== Set data schema version to 0.5.0 ==="
}
../clickhouse-schema-management
createTable
setDataVersion
kind: ConfigMap
metadata:
name: clickhouse-mounted-configmap
Expand Down Expand Up @@ -6386,8 +6365,6 @@ spec:
path: create_table.sh
- key: init.sh
path: init.sh
- key: 0-3-0_0-2-0.sql
path: migrators/downgrade/0-3-0_0-2-0.sql
- key: 000001_0-1-0.down.sql
path: migrators/000001_0-1-0.down.sql
- key: 000001_0-1-0.up.sql
Expand Down
4 changes: 4 additions & 0 deletions docs/network-flow-visibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ you use PersistentVolume for ClickHouse. To downgrade from v0.2 to v0.1, you
need to uninstall ClickHouse, delete related data if you use PersistenVolume
and redeploy it.

In v0.3, we add a breaking change to ClickHouse data migration. To downgrade
from a version after v0.3 to a version before v0.3 without data lossing. Please
first downgrade it to v0.3 and then to the version below v0.3.

A ClickHouse cluster consists of one or more shards. Shards refer to the servers
that contain different parts of the data. You can deploy multiple shards to scale
the cluster horizontally. Each shard consists of one or more replica hosts.
Expand Down

0 comments on commit fcbd0b6

Please sign in to comment.