mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-15 03:23:52 +00:00
24 lines
385 B
MySQL
24 lines
385 B
MySQL
|
-- +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
|