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