From 2abae8681dd86847c4531991ef384ebf566dbea1 Mon Sep 17 00:00:00 2001 From: TonyQ Date: Sat, 4 Dec 2021 02:05:02 +0000 Subject: [PATCH] fix #288 for adding migration --- README.md | 12 +++++++++-- ...204014905_update_taker_buy_base_volumn.sql | 21 +++++++++++++++++++ ...204014905_update_taker_buy_base_volumn.sql | 8 +++++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 migrations/mysql/20211204014905_update_taker_buy_base_volumn.sql create mode 100644 migrations/sqlite3/20211204014905_update_taker_buy_base_volumn.sql diff --git a/README.md b/README.md index 1fa24389e..8bc5094ac 100644 --- a/README.md +++ b/README.md @@ -566,6 +566,12 @@ The overview function flow at bbgo ### Adding new migration +1. The project used rockerhopper for db migration. +https://github.com/c9s/rockhopper + + +2. Create migration files + ```sh rockhopper --config rockhopper_sqlite.yaml create --type sql add_pnl_column rockhopper --config rockhopper_mysql.yaml create --type sql add_pnl_column @@ -577,9 +583,11 @@ or bash utils/generate-new-migration.sh add_pnl_column ``` -Be sure to edit both sqlite3 and mysql migration files. +Be sure to edit both sqlite3 and mysql migration files. ( [Sample] (migrations/mysql/20210531234123_add_kline_taker_buy_columns.sql) ) -To test the drivers, you can do: + +To test the drivers, you have to update the rockhopper_mysql.yaml file to connect your database, +then do: ```sh rockhopper --config rockhopper_sqlite.yaml up diff --git a/migrations/mysql/20211204014905_update_taker_buy_base_volumn.sql b/migrations/mysql/20211204014905_update_taker_buy_base_volumn.sql new file mode 100644 index 000000000..15d236a03 --- /dev/null +++ b/migrations/mysql/20211204014905_update_taker_buy_base_volumn.sql @@ -0,0 +1,21 @@ +-- +up +-- +begin +ALTER TABLE binance_klines CHANGE taker_buy_base_volume taker_buy_base_volume decimal(32,8) NOT NULL; +-- +end +-- +begin +ALTER TABLE max_klines CHANGE taker_buy_base_volume taker_buy_base_volume decimal(32,8) NOT NULL; +-- +end +-- +begin +ALTER TABLE okex_klines CHANGE taker_buy_base_volume taker_buy_base_volume decimal(32,8) NOT NULL; +-- +end + +-- +down +-- +begin +ALTER TABLE binance_klines CHANGE taker_buy_base_volume taker_buy_base_volume decimal(16,8) NOT NULL; +-- +end +-- +begin +ALTER TABLE max_klines CHANGE taker_buy_base_volume taker_buy_base_volume decimal(16,8) NOT NULL; +-- +end +-- +begin +ALTER TABLE okex_klines CHANGE taker_buy_base_volume taker_buy_base_volume decimal(16,8) NOT NULL; +-- +end diff --git a/migrations/sqlite3/20211204014905_update_taker_buy_base_volumn.sql b/migrations/sqlite3/20211204014905_update_taker_buy_base_volumn.sql new file mode 100644 index 000000000..a88ad32d4 --- /dev/null +++ b/migrations/sqlite3/20211204014905_update_taker_buy_base_volumn.sql @@ -0,0 +1,8 @@ +-- +up +-- +begin +-- +end + +-- +down + +-- +begin +-- +end