Skip to content

Commit 2a0938d

Browse files
guo0693yurishkuro
authored andcommitted
Improve migration script (#1946)
- continue migration if number of rows changed during migration - improve the sample command and remove unused TTL since it will be copied from old table Signed-off-by: Jun Guo <guo0693@gmail.com>
1 parent b3c76cd commit 2a0938d

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ Changes by Version
4747
1. You will need to run below command on the host you can use `cqlsh` to connect the the cassandra contact
4848
point
4949
```
50-
KEYSPACE=test_keyspace TIMEOUT=1000 CQL_CMD='cqlsh host 9042 -u test_user -p test_password' bash
51-
./plugin/storage/cassandra/schema/migration/v002tov003.sh
50+
KEYSPACE=jaeger_v1 CQL_CMD='cqlsh host 9042 -u test_user -p test_password --request-timeout=3000'
51+
bash ./v002tov003.sh
5252
```
5353
The script will create new table `operation_names_v2` and migrate data from the old table.
5454
`spanKind` column will be empty for those data.

plugin/storage/cassandra/schema/migration/V002toV003.sh

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/usr/bin/env bash
22

33
# Create a new operation_names_v2 table and copy all data from operation_names table
4-
# Sample usage: KEYSPACE=jaeger_v1 TIMEOUT=1000 CQL_CMD='cqlsh host 9042 -u test_user -p test_password' bash
4+
# Sample usage: KEYSPACE=jaeger_v1 CQL_CMD='cqlsh host 9042 -u test_user -p test_password --request-timeout=3000' bash
55
# ./v002tov003.sh
66

77
set -euo pipefail
88

99
function usage {
1010
>&2 echo "Error: $1"
1111
>&2 echo ""
12-
>&2 echo "Usage: KEYSPACE={keyspace} TTL={ttl} CQL_CMD={cql_cmd}$0"
12+
>&2 echo "Usage: KEYSPACE={keyspace} CQL_CMD={cql_cmd} $0"
1313
>&2 echo ""
1414
>&2 echo "The following parameters can be set via environment:"
1515
>&2 echo " KEYSPACE - keyspace"
@@ -64,11 +64,6 @@ fi
6464

6565
csv_rows=$(wc -l ${old_table}.csv | tr -dc '0-9')
6666

67-
if [[ ${row_count} -ne ${csv_rows} ]]; then
68-
echo "Number of rows: $csv_rows in file is not equal to number of rows: $row_count in cassandra"
69-
exit 1
70-
fi
71-
7267
echo "Generating data for new table..."
7368
while IFS="," read service_name operation_name; do
7469
echo "$service_name,,$operation_name"

0 commit comments

Comments
 (0)