diff --git a/migrations/mysql/20211211034819_add_nav_history_details.sql b/migrations/mysql/20211211034819_add_nav_history_details.sql index 53c8534e6..965fe800f 100644 --- a/migrations/mysql/20211211034819_add_nav_history_details.sql +++ b/migrations/mysql/20211211034819_add_nav_history_details.sql @@ -2,21 +2,21 @@ -- +begin CREATE TABLE nav_history_details ( - gid bigint unsigned auto_increment PRIMARY KEY, - exchange VARCHAR(30) NOT NULL, - subaccount VARCHAR(30) NOT NULL, - time DATETIME(3) NOT NULL, - currency VARCHAR(12) NOT NULL, - balance_in_usd DECIMAL(32, 8) UNSIGNED DEFAULT 0.00000000 NOT NULL, - balance_in_btc DECIMAL(32, 8) UNSIGNED DEFAULT 0.00000000 NOT NULL, - balance DECIMAL(32, 8) UNSIGNED DEFAULT 0.00000000 NOT NULL, - available DECIMAL(32, 8) UNSIGNED DEFAULT 0.00000000 NOT NULL, - locked DECIMAL(32, 8) UNSIGNED DEFAULT 0.00000000 NOT NULL + gid bigint unsigned auto_increment PRIMARY KEY, + exchange VARCHAR(30) NOT NULL, + subaccount VARCHAR(30) NOT NULL, + time DATETIME(3) NOT NULL, + currency VARCHAR(12) NOT NULL, + balance_in_usd DECIMAL(32, 8) UNSIGNED DEFAULT 0.00000000 NOT NULL, + balance_in_btc DECIMAL(32, 8) UNSIGNED DEFAULT 0.00000000 NOT NULL, + balance DECIMAL(32, 8) UNSIGNED DEFAULT 0.00000000 NOT NULL, + available DECIMAL(32, 8) UNSIGNED DEFAULT 0.00000000 NOT NULL, + locked DECIMAL(32, 8) UNSIGNED DEFAULT 0.00000000 NOT NULL ); -- +end -- +begin CREATE INDEX idx_nav_history_details - on nav_history_details(time, currency, exchange); + on nav_history_details (time, currency, exchange); -- +end -- +down diff --git a/migrations/mysql/20220503144849_add_margin_info_to_nav.sql b/migrations/mysql/20220503144849_add_margin_info_to_nav.sql new file mode 100644 index 000000000..9849b8818 --- /dev/null +++ b/migrations/mysql/20220503144849_add_margin_info_to_nav.sql @@ -0,0 +1,19 @@ +-- +up +-- +begin +ALTER TABLE `nav_history_details` + ADD COLUMN `net_asset` DECIMAL(32, 8) UNSIGNED DEFAULT 0.00000000 NOT NULL, + ADD COLUMN `borrowed` DECIMAL(32, 8) UNSIGNED DEFAULT 0.00000000 NOT NULL, + ADD COLUMN `price_in_usd` DECIMAL(32, 8) UNSIGNED DEFAULT 0.00000000 NOT NULL +; +-- +end + + +-- +down + +-- +begin +ALTER TABLE `nav_history_details` + DROP COLUMN `net_asset`, + DROP COLUMN `borrowed`, + DROP COLUMN `price_in_usd` +; +-- +end diff --git a/migrations/sqlite3/20220503144849_add_margin_info_to_nav.sql b/migrations/sqlite3/20220503144849_add_margin_info_to_nav.sql new file mode 100644 index 000000000..f1ce6baaa --- /dev/null +++ b/migrations/sqlite3/20220503144849_add_margin_info_to_nav.sql @@ -0,0 +1,8 @@ +-- +up +ALTER TABLE `nav_history_details` ADD COLUMN `borrowed` DECIMAL UNSIGNED DEFAULT 0.00000000 NOT NULL; +ALTER TABLE `nav_history_details` ADD COLUMN `net_asset` DECIMAL UNSIGNED DEFAULT 0.00000000 NOT NULL; +ALTER TABLE `nav_history_details` ADD COLUMN `price_in_usd` DECIMAL UNSIGNED DEFAULT 0.00000000 NOT NULL; + +-- +down +-- we can not rollback alter table change in sqlite +SELECT 1;