mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
Compare commits
5 Commits
6a803d5a4c
...
a6c1337493
Author | SHA1 | Date | |
---|---|---|---|
|
a6c1337493 | ||
|
37106c35b7 | ||
|
8265ada5a0 | ||
|
744ca57c71 | ||
|
0a0620b870 |
10
migrations/mysql/20240918132534_add_position_index.sql
Normal file
10
migrations/mysql/20240918132534_add_position_index.sql
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
-- +up
|
||||||
|
-- +begin
|
||||||
|
CREATE INDEX positions_traded_at ON positions (traded_at, profit);
|
||||||
|
-- +end
|
||||||
|
|
||||||
|
-- +down
|
||||||
|
|
||||||
|
-- +begin
|
||||||
|
DROP INDEX positions_traded_at ON positions;
|
||||||
|
-- +end
|
10
migrations/sqlite3/20240918132534_add_position_index.sql
Normal file
10
migrations/sqlite3/20240918132534_add_position_index.sql
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
-- +up
|
||||||
|
-- +begin
|
||||||
|
CREATE INDEX positions_traded_at ON positions (traded_at, profit);
|
||||||
|
-- +end
|
||||||
|
|
||||||
|
-- +down
|
||||||
|
|
||||||
|
-- +begin
|
||||||
|
DROP INDEX positions_traded_at;
|
||||||
|
-- +end
|
|
@ -91,6 +91,10 @@ func PrintConfig(s interface{}, f io.Writer, style *table.Style, withColor bool,
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if jtag := tt.Tag.Get("json"); jtag != "" && jtag != "-" {
|
if jtag := tt.Tag.Get("json"); jtag != "" && jtag != "-" {
|
||||||
|
unprintable := tt.Tag.Get("unprintable")
|
||||||
|
if unprintable == "true" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
name := strings.Split(jtag, ",")[0]
|
name := strings.Split(jtag, ",")[0]
|
||||||
if _, ok := redundantSet[name]; ok {
|
if _, ok := redundantSet[name]; ok {
|
||||||
continue
|
continue
|
||||||
|
@ -106,6 +110,10 @@ func PrintConfig(s interface{}, f io.Writer, style *table.Style, withColor bool,
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
name := strings.Split(jsonTag, ",")[0]
|
name := strings.Split(jsonTag, ",")[0]
|
||||||
|
unprintable := t.Tag.Get("unprintable")
|
||||||
|
if unprintable == "true" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if _, ok := redundantSet[name]; ok {
|
if _, ok := redundantSet[name]; ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package mysql
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/c9s/rockhopper/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
AddMigration("main", up_main_addPositionIndex, down_main_addPositionIndex)
|
||||||
|
}
|
||||||
|
|
||||||
|
func up_main_addPositionIndex(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||||
|
// This code is executed when the migration is applied.
|
||||||
|
_, err = tx.ExecContext(ctx, "CREATE INDEX positions_traded_at ON positions (traded_at, profit);")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func down_main_addPositionIndex(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||||
|
// This code is executed when the migration is rolled back.
|
||||||
|
_, err = tx.ExecContext(ctx, "DROP INDEX positions_traded_at ON positions;")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package sqlite3
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/c9s/rockhopper/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
AddMigration("main", up_main_addPositionIndex, down_main_addPositionIndex)
|
||||||
|
}
|
||||||
|
|
||||||
|
func up_main_addPositionIndex(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||||
|
// This code is executed when the migration is applied.
|
||||||
|
_, err = tx.ExecContext(ctx, "CREATE INDEX positions_traded_at ON positions (traded_at, profit);")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func down_main_addPositionIndex(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||||
|
// This code is executed when the migration is rolled back.
|
||||||
|
_, err = tx.ExecContext(ctx, "DROP INDEX positions_traded_at;")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user