From f1bce94d4d01297470852b931577749327396c4a Mon Sep 17 00:00:00 2001 From: c9s Date: Fri, 5 Feb 2021 14:20:07 +0800 Subject: [PATCH] add script for testing sqlite3 migration --- .travis.yml | 1 + migrations/sqlite3/20200819054742_trade_index.sql | 6 +++--- migrations/sqlite3/20201105092857_trades_index_fix.sql | 6 +++--- scripts/test-sqlite3-migrations.sh | 2 ++ 4 files changed, 9 insertions(+), 6 deletions(-) create mode 100755 scripts/test-sqlite3-migrations.sh diff --git a/.travis.yml b/.travis.yml index ac48e49fe0..595d79af6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,4 +9,5 @@ before_script: - go get github.com/c9s/rockhopper - go mod download script: +- bash scripts/test-sqlite3-migrations.sh - go test -v ./pkg/... diff --git a/migrations/sqlite3/20200819054742_trade_index.sql b/migrations/sqlite3/20200819054742_trade_index.sql index 6ce90b1bd9..e6dba452be 100644 --- a/migrations/sqlite3/20200819054742_trade_index.sql +++ b/migrations/sqlite3/20200819054742_trade_index.sql @@ -4,6 +4,6 @@ CREATE INDEX trades_symbol_fee_currency ON trades(symbol, fee_currency, traded_a CREATE INDEX trades_traded_at_symbol ON trades(traded_at, symbol); -- +down -DROP INDEX trades_symbol ON trades; -DROP INDEX trades_symbol_fee_currency ON trades; -DROP INDEX trades_traded_at_symbol ON trades; +DROP INDEX trades_symbol; +DROP INDEX trades_symbol_fee_currency; +DROP INDEX trades_traded_at_symbol; diff --git a/migrations/sqlite3/20201105092857_trades_index_fix.sql b/migrations/sqlite3/20201105092857_trades_index_fix.sql index 44f58e7682..30a9554063 100644 --- a/migrations/sqlite3/20201105092857_trades_index_fix.sql +++ b/migrations/sqlite3/20201105092857_trades_index_fix.sql @@ -8,9 +8,9 @@ CREATE INDEX trades_symbol_fee_currency ON trades (exchange, symbol, fee_currenc CREATE INDEX trades_traded_at_symbol ON trades (exchange, traded_at, symbol); -- +down -DROP INDEX IF EXISTS trades_symbol ON trades; -DROP INDEX IF EXISTS trades_symbol_fee_currency ON trades; -DROP INDEX IF EXISTS trades_traded_at_symbol ON trades; +DROP INDEX IF EXISTS trades_symbol; +DROP INDEX IF EXISTS trades_symbol_fee_currency; +DROP INDEX IF EXISTS trades_traded_at_symbol; CREATE INDEX trades_symbol ON trades (symbol); CREATE INDEX trades_symbol_fee_currency ON trades (symbol, fee_currency, traded_at); diff --git a/scripts/test-sqlite3-migrations.sh b/scripts/test-sqlite3-migrations.sh new file mode 100755 index 0000000000..83c5b683c4 --- /dev/null +++ b/scripts/test-sqlite3-migrations.sh @@ -0,0 +1,2 @@ +#!/bin/bash +rm -v bbgo.sqlite3 && rockhopper --config rockhopper_sqlite.yaml up && rockhopper --config rockhopper_sqlite.yaml down --to 1