From 157d1f3bbe94c2798206f0d62a211db1ab2119b2 Mon Sep 17 00:00:00 2001 From: c9s Date: Fri, 11 Mar 2022 13:49:32 +0800 Subject: [PATCH] migrations: update position table columns --- migrations/mysql/20220307132917_add_positions.sql | 9 ++++++--- migrations/sqlite3/20220307132917_add_positions.sql | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/migrations/mysql/20220307132917_add_positions.sql b/migrations/mysql/20220307132917_add_positions.sql index 38b5b45b2..ca10e14d9 100644 --- a/migrations/mysql/20220307132917_add_positions.sql +++ b/migrations/mysql/20220307132917_add_positions.sql @@ -16,11 +16,14 @@ CREATE TABLE `positions` `quote` DECIMAL(16, 8) NOT NULL, `profit` DECIMAL(16, 8) NULL, - `trade_id` BIGINT UNSIGNED NOT NULL, - `traded_at` DATETIME(3) NOT NULL, + -- trade related columns + `trade_id` BIGINT UNSIGNED NOT NULL, -- the trade id in the exchange + `side` VARCHAR(4) NOT NULL, -- side of the trade + `exchange` VARCHAR(12) NOT NULL, -- exchange of the trade + `traded_at` DATETIME(3) NOT NULL, -- millisecond timestamp PRIMARY KEY (`gid`), - UNIQUE KEY `trade_id` (`trade_id`) + UNIQUE KEY `trade_id` (`trade_id`, `side`, `exchange`) ); -- +down diff --git a/migrations/sqlite3/20220307132917_add_positions.sql b/migrations/sqlite3/20220307132917_add_positions.sql index 8ffb43a49..90569dfba 100644 --- a/migrations/sqlite3/20220307132917_add_positions.sql +++ b/migrations/sqlite3/20220307132917_add_positions.sql @@ -16,8 +16,12 @@ CREATE TABLE `positions` `quote` DECIMAL(16, 8) NOT NULL, `profit` DECIMAL(16, 8) NULL, + -- trade related columns `trade_id` BIGINT NOT NULL, + `side` VARCHAR(4) NOT NULL, -- side of the trade + `exchange` VARCHAR(12) NOT NULL, -- exchange of the trade `traded_at` DATETIME(3) NOT NULL + ); -- +down