bbgo_origin/pkg/migrations/sqlite3/main_20220531013541_margin_interests.go

31 lines
1.1 KiB
Go
Raw Normal View History

2022-05-31 09:30:24 +00:00
package sqlite3
import (
"context"
2024-01-18 13:36:04 +00:00
"github.com/c9s/rockhopper/v2"
2022-05-31 09:30:24 +00:00
)
func init() {
2024-01-18 13:36:04 +00:00
AddMigration("main", up_main_marginInterests, down_main_marginInterests)
2022-05-31 09:30:24 +00:00
}
2024-01-18 13:36:04 +00:00
func up_main_marginInterests(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
2022-05-31 09:30:24 +00:00
// This code is executed when the migration is applied.
_, err = tx.ExecContext(ctx, "CREATE TABLE `margin_interests`\n(\n `gid` INTEGER PRIMARY KEY AUTOINCREMENT,\n `exchange` VARCHAR(24) NOT NULL DEFAULT '',\n `asset` VARCHAR(24) NOT NULL DEFAULT '',\n `isolated_symbol` VARCHAR(24) NOT NULL DEFAULT '',\n `principle` DECIMAL(16, 8) NOT NULL,\n `interest` DECIMAL(20, 16) NOT NULL,\n `interest_rate` DECIMAL(20, 16) NOT NULL,\n `time` DATETIME(3) NOT NULL\n);")
if err != nil {
return err
}
return err
}
2024-01-18 13:36:04 +00:00
func down_main_marginInterests(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
2022-05-31 09:30:24 +00:00
// This code is executed when the migration is rolled back.
_, err = tx.ExecContext(ctx, "DROP TABLE IF EXISTS `margin_interests`;")
if err != nil {
return err
}
return err
}