add margin history migrations

This commit is contained in:
c9s 2022-05-31 01:40:21 +08:00
parent c3f2c9eb4a
commit 17e575df33
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
6 changed files with 141 additions and 0 deletions

View File

@ -0,0 +1,24 @@
-- +up
CREATE TABLE `margin_loans`
(
`gid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`transaction_id` BIGINT UNSIGNED NOT NULL,
`exchange` VARCHAR(24) NOT NULL DEFAULT '',
`asset` VARCHAR(24) NOT NULL DEFAULT '',
`isolated_symbol` VARCHAR(24) NOT NULL DEFAULT '',
-- quantity is the quantity of the trade that makes profit
`principle` DECIMAL(16, 8) UNSIGNED NOT NULL,
`time` DATETIME(3) NOT NULL,
PRIMARY KEY (`gid`),
UNIQUE KEY (`transaction_id`)
);
-- +down
DROP TABLE IF EXISTS `margin_loans`;

View File

@ -0,0 +1,24 @@
-- +up
CREATE TABLE `margin_repays`
(
`gid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`transaction_id` BIGINT UNSIGNED NOT NULL,
`exchange` VARCHAR(24) NOT NULL DEFAULT '',
`asset` VARCHAR(24) NOT NULL DEFAULT '',
`isolated_symbol` VARCHAR(24) NOT NULL DEFAULT '',
-- quantity is the quantity of the trade that makes profit
`principle` DECIMAL(16, 8) UNSIGNED NOT NULL,
`time` DATETIME(3) NOT NULL,
PRIMARY KEY (`gid`),
UNIQUE KEY (`transaction_id`)
);
-- +down
DROP TABLE IF EXISTS `margin_repays`;

View File

@ -0,0 +1,27 @@
-- +up
CREATE TABLE `margin_interests`
(
`gid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`transaction_id` BIGINT UNSIGNED NOT NULL,
`exchange` VARCHAR(24) NOT NULL DEFAULT '',
`asset` VARCHAR(24) NOT NULL DEFAULT '',
`isolated_symbol` VARCHAR(24) NOT NULL DEFAULT '',
`principle` DECIMAL(16, 8) UNSIGNED NOT NULL,
`interest` DECIMAL(20, 16) UNSIGNED NOT NULL,
`interest_rate` DECIMAL(20, 16) UNSIGNED NOT NULL,
`time` DATETIME(3) NOT NULL,
PRIMARY KEY (`gid`),
UNIQUE KEY (`transaction_id`)
);
-- +down
DROP TABLE IF EXISTS `margin_interests`;

View File

@ -0,0 +1,21 @@
-- +up
CREATE TABLE `margin_loans`
(
`gid` INTEGER PRIMARY KEY AUTOINCREMENT,
`transaction_id` INTEGER NOT NULL,
`exchange` VARCHAR(24) NOT NULL DEFAULT '',
`asset` VARCHAR(24) NOT NULL DEFAULT '',
`isolated_symbol` VARCHAR(24) NOT NULL DEFAULT '',
-- quantity is the quantity of the trade that makes profit
`principle` DECIMAL(16, 8) NOT NULL,
`time` DATETIME(3) NOT NULL
);
-- +down
DROP TABLE IF EXISTS `margin_loans`;

View File

@ -0,0 +1,21 @@
-- +up
CREATE TABLE `margin_repays`
(
`gid` INTEGER PRIMARY KEY AUTOINCREMENT,
`transaction_id` INTEGER NOT NULL,
`exchange` VARCHAR(24) NOT NULL DEFAULT '',
`asset` VARCHAR(24) NOT NULL DEFAULT '',
`isolated_symbol` VARCHAR(24) NOT NULL DEFAULT '',
-- quantity is the quantity of the trade that makes profit
`principle` DECIMAL(16, 8) NOT NULL,
`time` DATETIME(3) NOT NULL
);
-- +down
DROP TABLE IF EXISTS `margin_repays`;

View File

@ -0,0 +1,24 @@
-- +up
CREATE TABLE `margin_interests`
(
`gid` INTEGER PRIMARY KEY AUTOINCREMENT,
`transaction_id` INTEGER NOT NULL,
`exchange` VARCHAR(24) NOT NULL DEFAULT '',
`asset` VARCHAR(24) NOT NULL DEFAULT '',
`isolated_symbol` VARCHAR(24) NOT NULL DEFAULT '',
`principle` DECIMAL(16, 8) NOT NULL,
`interest` DECIMAL(20, 16) NOT NULL,
`interest_rate` DECIMAL(20, 16) NOT NULL,
`time` DATETIME(3) NOT NULL
);
-- +down
DROP TABLE IF EXISTS `margin_interests`;