Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve migration script #1946

Merged
merged 1 commit into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ Changes by Version
1. You will need to run below command on the host you can use `cqlsh` to connect the the cassandra contact
point
```
KEYSPACE=test_keyspace TIMEOUT=1000 CQL_CMD='cqlsh host 9042 -u test_user -p test_password' bash
./plugin/storage/cassandra/schema/migration/v002tov003.sh
KEYSPACE=jaeger_v1 CQL_CMD='cqlsh host 9042 -u test_user -p test_password --request-timeout=3000'
bash ./v002tov003.sh
```
The script will create new table `operation_names_v2` and migrate data from the old table.
`spanKind` column will be empty for those data.
Expand Down
9 changes: 2 additions & 7 deletions plugin/storage/cassandra/schema/migration/V002toV003.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/env bash

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

set -euo pipefail

function usage {
>&2 echo "Error: $1"
>&2 echo ""
>&2 echo "Usage: KEYSPACE={keyspace} TTL={ttl} CQL_CMD={cql_cmd}$0"
>&2 echo "Usage: KEYSPACE={keyspace} CQL_CMD={cql_cmd} $0"
>&2 echo ""
>&2 echo "The following parameters can be set via environment:"
>&2 echo " KEYSPACE - keyspace"
Expand Down Expand Up @@ -64,11 +64,6 @@ fi

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

if [[ ${row_count} -ne ${csv_rows} ]]; then
echo "Number of rows: $csv_rows in file is not equal to number of rows: $row_count in cassandra"
exit 1
fi

echo "Generating data for new table..."
while IFS="," read service_name operation_name; do
echo "$service_name,,$operation_name"
Expand Down