mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
Compare commits
4 Commits
6a803d5a4c
...
a6c1337493
Author | SHA1 | Date | |
---|---|---|---|
|
a6c1337493 | ||
|
37106c35b7 | ||
|
8265ada5a0 | ||
|
744ca57c71 |
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
|
|
@ -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