Skip to content

Commit

Permalink
Improved sed process
Browse files Browse the repository at this point in the history
Signed-off-by: Nana-EC <[email protected]>
  • Loading branch information
Nana-EC committed Jan 4, 2021
1 parent 59df562 commit 7fe49cc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ services:
environment:
POSTGRES_PASSWORD: mirror_node_pass
volumes:
- ./tsdb:/var/lib/postgresql/data
- ./timescaledb:/var/lib/postgresql/data
- ./hedera-mirror-importer/src/main/resources/db/scripts/init_v2.sql/:/docker-entrypoint-initdb.d/init_v2.sql
ports:
- 5432:5432
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ NEW_DB_NAME=mirror_node
NEW_DB_PORT=6432
NEW_DB_USER=mirror_node
NEW_PASSWORD=mirror_node_pass
CHUNK_INTERVAL_TIME=604800000000000
CHUNK_INTERVAL_ID=10000
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,8 @@ echo "3. Create v2 table schemas in TimescaleDB($NEW_DB_HOST:$NEW_DB_PORT)..."
PGPASSWORD=${NEW_PASSWORD} psql -h $NEW_DB_HOST -d $NEW_DB_NAME -p $NEW_DB_PORT -U $NEW_DB_USER <migration/v2/V2.0.0__time_scale_init.sql

echo "4. Creating new hyper tables on TimescaleDB($NEW_DB_HOST:$NEW_DB_PORT)..."
sed 's/${chunkTimeInterval}/'$CHUNK_INTERVAL_TIME'/g' migration/v2/V2.0.1__hyper_tables.sql >scripts/timescaledb/createHyperTables_0.sql
sed 's/${chunkIdInterval}/'$CHUNK_INTERVAL_ID'/g' scripts/timescaledb/createHyperTables_0.sql >scripts/timescaledb/createHyperTables.sql
sed -e 's/${chunkTimeInterval}/'$CHUNK_INTERVAL_TIME'/g' -e 's/${chunkIdInterval}/'$CHUNK_INTERVAL_ID'/g' migration/v2/V2.0.1__hyper_tables.sql >scripts/timescaledb/createHyperTables.sql
PGPASSWORD=${NEW_PASSWORD} psql -h $NEW_DB_HOST -d $NEW_DB_NAME -p $NEW_DB_PORT -U $NEW_DB_USER -f scripts/timescaledb/createHyperTables.sql
rm scripts/timescaledb/createHyperTables_0.sql
rm scripts/timescaledb/createHyperTables.sql

echo "5. Backing up tables from from Postgres($OLD_DB_HOST:$OLD_DB_PORT) to separate CSV's..."
PGPASSWORD=${OLD_PASSWORD} psql -h $OLD_DB_HOST -d $OLD_DB_NAME -p $OLD_DB_PORT -U $OLD_DB_USER -f scripts/timescaledb/csvBackupTables.sql
Expand Down

0 comments on commit 7fe49cc

Please sign in to comment.