mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
Merge pull request #1646 from c9s/minor/add-inserted-at-to-trade
MINOR: add inserted_at column to trades
This commit is contained in:
commit
c83524a04a
14
migrations/mysql/20240531163411_trades_created.sql
Normal file
14
migrations/mysql/20240531163411_trades_created.sql
Normal file
|
@ -0,0 +1,14 @@
|
|||
-- +up
|
||||
-- +begin
|
||||
ALTER TABLE `trades` ADD COLUMN `inserted_at` DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL AFTER `traded_at`;
|
||||
-- +end
|
||||
|
||||
-- +begin
|
||||
UPDATE `trades` SET `inserted_at`=`traded_at`;
|
||||
-- +end
|
||||
|
||||
-- +down
|
||||
|
||||
-- +begin
|
||||
ALTER TABLE `trades` DROP COLUMN `inserted_at`;
|
||||
-- +end
|
23
migrations/sqlite3/20240531163411_trades_created.sql
Normal file
23
migrations/sqlite3/20240531163411_trades_created.sql
Normal file
|
@ -0,0 +1,23 @@
|
|||
-- +up
|
||||
-- +begin
|
||||
ALTER TABLE trades ADD COLUMN inserted_at TEXT;
|
||||
|
||||
UPDATE trades SET inserted_at = traded_at;
|
||||
|
||||
CREATE TRIGGER set_inserted_at
|
||||
AFTER INSERT ON trades
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
UPDATE trades
|
||||
SET inserted_at = datetime('now')
|
||||
WHERE rowid = NEW.rowid;
|
||||
END;
|
||||
|
||||
-- +end
|
||||
|
||||
-- +down
|
||||
|
||||
-- +begin
|
||||
DROP TRIGGER set_inserted_at;
|
||||
ALTER TABLE trades DROP COLUMN inserted_at;
|
||||
-- +end
|
|
@ -95,6 +95,8 @@ type Trade struct {
|
|||
|
||||
// PnL is the profit and loss value of the executed trade
|
||||
PnL sql.NullFloat64 `json:"pnl" db:"pnl"`
|
||||
|
||||
InsertedAt Time `json:"insertedAt" db:"inserted_at"`
|
||||
}
|
||||
|
||||
func (trade Trade) CsvHeader() []string {
|
||||
|
|
Loading…
Reference in New Issue
Block a user