Compare commits
1 commit
main
...
testmigrat
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d22d0299fd |
3 changed files with 13 additions and 11 deletions
|
|
@ -1,13 +1,13 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
set -ex
|
||||||
|
|
||||||
clickhousedir=/opt/openreplay/openreplay/scripts/helm/db/init_dbs/clickhouse
|
clickhousedir=/opt/openreplay/openreplay/scripts/helm/db/init_dbs/clickhouse
|
||||||
|
|
||||||
function migrate() {
|
function migrate() {
|
||||||
echo "Starting clickhouse migration"
|
echo "Starting clickhouse migration"
|
||||||
migration_versions=$1
|
IFS=',' read -r -a migration_versions <<< "$1"
|
||||||
for version in $migration_versions; do
|
for version in ${migration_versions[*]}; do
|
||||||
echo "Migrating clickhouse version $version"
|
echo "Migrating clickhouse version $version"
|
||||||
# For now, we can ignore the clickhouse db inject errors.
|
# For now, we can ignore the clickhouse db inject errors.
|
||||||
# TODO: Better error handling in script
|
# TODO: Better error handling in script
|
||||||
|
|
|
||||||
|
|
@ -27,22 +27,24 @@ function migration() {
|
||||||
# Checking migration versions
|
# Checking migration versions
|
||||||
cd /opt/openreplay/openreplay/scripts/helm
|
cd /opt/openreplay/openreplay/scripts/helm
|
||||||
migration_versions=(`ls -l db/init_dbs/$db | grep -E ^d | awk -v number=${PREVIOUS_APP_VERSION} '$NF > number {print $NF}' | grep -v create`)
|
migration_versions=(`ls -l db/init_dbs/$db | grep -E ^d | awk -v number=${PREVIOUS_APP_VERSION} '$NF > number {print $NF}' | grep -v create`)
|
||||||
echo "Migration version: $migration_versions"
|
echo "Migration version: ${migration_versions[*]}"
|
||||||
|
# Can't pass the space seperated array to ansible for migration. So joining them with ,
|
||||||
|
joined_migration_versions=$(IFS=, ; echo "${migration_versions[*]}")
|
||||||
|
|
||||||
cd -
|
cd -
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
postgresql)
|
postgresql)
|
||||||
/bin/bash postgresql.sh migrate $migration_versions
|
/bin/bash postgresql.sh migrate $joined_migration_versions
|
||||||
;;
|
;;
|
||||||
minio)
|
minio)
|
||||||
/bin/bash minio.sh migrate $migration_versions
|
/bin/bash minio.sh migrate $joined_migration_versions
|
||||||
;;
|
;;
|
||||||
clickhouse)
|
clickhouse)
|
||||||
/bin/bash clickhouse.sh migrate $migration_versions
|
/bin/bash clickhouse.sh migrate $joined_migration_versions
|
||||||
;;
|
;;
|
||||||
kafka)
|
kafka)
|
||||||
/bin/bash kafka.sh migrate $migration_versions
|
/bin/bash kafka.sh migrate $joined_migration_versions
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown operation for db migration; exiting."
|
echo "Unknown operation for db migration; exiting."
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
set -ex
|
||||||
|
|
||||||
pgdir=/opt/openreplay/openreplay/scripts/helm/db/init_dbs/postgresql
|
pgdir=/opt/openreplay/openreplay/scripts/helm/db/init_dbs/postgresql
|
||||||
|
|
||||||
|
|
@ -14,8 +14,8 @@ pgdir=/opt/openreplay/openreplay/scripts/helm/db/init_dbs/postgresql
|
||||||
|
|
||||||
function migrate() {
|
function migrate() {
|
||||||
echo "Starting postgresql migration"
|
echo "Starting postgresql migration"
|
||||||
migration_versions=$1
|
IFS=',' read -r -a migration_versions <<< "$1"
|
||||||
for version in $migration_versions; do
|
for version in ${migration_versions[*]}; do
|
||||||
echo "Migrating postgresql version $version"
|
echo "Migrating postgresql version $version"
|
||||||
psql -f ${pgdir}/${version}/${version}.sql
|
psql -f ${pgdir}/${version}/${version}.sql
|
||||||
done
|
done
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue