mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
Merge pull request #1511 from c9s/c9s/update-migrations
MINOR: compile and update migration package
This commit is contained in:
commit
f18433409d
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_trades, down_main_trades)
|
||||
|
||||
}
|
||||
|
||||
func up_main_trades(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_tradeIndex, down_main_tradeIndex)
|
||||
|
||||
}
|
||||
|
||||
func up_main_tradeIndex(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_orders, down_main_orders)
|
||||
|
||||
}
|
||||
|
||||
func up_main_orders(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_tradesAddOrderId, down_main_tradesAddOrderId)
|
||||
|
||||
}
|
||||
|
||||
func up_main_tradesAddOrderId(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_tradesIndexFix, down_main_tradesIndexFix)
|
||||
|
||||
}
|
||||
|
||||
func up_main_tradesIndexFix(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_ordersAddIndex, down_main_ordersAddIndex)
|
||||
|
||||
}
|
||||
|
||||
func up_main_ordersAddIndex(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_klines, down_main_klines)
|
||||
|
||||
}
|
||||
|
||||
func up_main_klines(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_fixSymbolLength, down_main_fixSymbolLength)
|
||||
|
||||
}
|
||||
|
||||
func up_main_fixSymbolLength(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_fixUniqueIndex, down_main_fixUniqueIndex)
|
||||
|
||||
}
|
||||
|
||||
func up_main_fixUniqueIndex(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addMarginColumns, down_main_addMarginColumns)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addMarginColumns(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_tradePriceQuantityIndex, down_main_tradePriceQuantityIndex)
|
||||
|
||||
}
|
||||
|
||||
func up_main_tradePriceQuantityIndex(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addPnlColumn, down_main_addPnlColumn)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addPnlColumn(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addRewardsTable, down_main_addRewardsTable)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addRewardsTable(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addWithdrawsTable, down_main_addWithdrawsTable)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addWithdrawsTable(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addDepositsTable, down_main_addDepositsTable)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addDepositsTable(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_klinesSymbolLength, down_main_klinesSymbolLength)
|
||||
|
||||
}
|
||||
|
||||
func up_main_klinesSymbolLength(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_increaseSymbolLength, down_main_increaseSymbolLength)
|
||||
|
||||
}
|
||||
|
||||
func up_main_increaseSymbolLength(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_increaseDecimalLength, down_main_increaseDecimalLength)
|
||||
|
||||
}
|
||||
|
||||
func up_main_increaseDecimalLength(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addKlineTakerBuyColumns, down_main_addKlineTakerBuyColumns)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addKlineTakerBuyColumns(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addIsFuturesColumn, down_main_addIsFuturesColumn)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addIsFuturesColumn(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addFtxKline, down_main_addFtxKline)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addFtxKline(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addNavHistoryDetails, down_main_addNavHistoryDetails)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addNavHistoryDetails(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_updateFeeCurrencyLength, down_main_updateFeeCurrencyLength)
|
||||
|
||||
}
|
||||
|
||||
func up_main_updateFeeCurrencyLength(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addKucoinKlines, down_main_addKucoinKlines)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addKucoinKlines(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addProfitTable, down_main_addProfitTable)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addProfitTable(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addPositions, down_main_addPositions)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addPositions(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_fixTradeIndexes, down_main_fixTradeIndexes)
|
||||
|
||||
}
|
||||
|
||||
func up_main_fixTradeIndexes(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_fixFeeColumn, down_main_fixFeeColumn)
|
||||
|
||||
}
|
||||
|
||||
func up_main_fixFeeColumn(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addMarginInfoToNav, down_main_addMarginInfoToNav)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addMarginInfoToNav(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_fixNetAssetColumn, down_main_fixNetAssetColumn)
|
||||
|
||||
}
|
||||
|
||||
func up_main_fixNetAssetColumn(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_fixProfitSymbolLength, down_main_fixProfitSymbolLength)
|
||||
|
||||
}
|
||||
|
||||
func up_main_fixProfitSymbolLength(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_klineUniqueIdx, down_main_klineUniqueIdx)
|
||||
|
||||
}
|
||||
|
||||
func up_main_klineUniqueIdx(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_marginLoans, down_main_marginLoans)
|
||||
|
||||
}
|
||||
|
||||
func up_main_marginLoans(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_marginRepays, down_main_marginRepays)
|
||||
|
||||
}
|
||||
|
||||
func up_main_marginRepays(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_marginInterests, down_main_marginInterests)
|
||||
|
||||
}
|
||||
|
||||
func up_main_marginInterests(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_marginLiquidations, down_main_marginLiquidations)
|
||||
|
||||
}
|
||||
|
||||
func up_main_marginLiquidations(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addBybitKlines, down_main_addBybitKlines)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addBybitKlines(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_fixOrderStatusLength, down_main_fixOrderStatusLength)
|
||||
|
||||
}
|
||||
|
||||
func up_main_fixOrderStatusLength(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -9,14 +9,9 @@ import (
|
|||
"github.com/c9s/rockhopper/v2"
|
||||
)
|
||||
|
||||
type registryKey struct {
|
||||
Package string
|
||||
Version int64
|
||||
}
|
||||
var registeredGoMigrations = map[rockhopper.RegistryKey]*rockhopper.Migration{}
|
||||
|
||||
var registeredGoMigrations = map[registryKey]*rockhopper.Migration{}
|
||||
|
||||
func MergeMigrationsMap(ms map[registryKey]*rockhopper.Migration) {
|
||||
func MergeMigrationsMap(ms map[rockhopper.RegistryKey]*rockhopper.Migration) {
|
||||
for k, m := range ms {
|
||||
if _, ok := registeredGoMigrations[k]; !ok {
|
||||
registeredGoMigrations[k] = m
|
||||
|
@ -26,7 +21,7 @@ func MergeMigrationsMap(ms map[registryKey]*rockhopper.Migration) {
|
|||
}
|
||||
}
|
||||
|
||||
func GetMigrationsMap() map[registryKey]*rockhopper.Migration {
|
||||
func GetMigrationsMap() map[rockhopper.RegistryKey]*rockhopper.Migration {
|
||||
return registeredGoMigrations
|
||||
}
|
||||
|
||||
|
@ -71,10 +66,6 @@ func _parseFuncPackageName(funcName string) string {
|
|||
|
||||
// AddNamedMigration adds a named migration to the registered go migration map
|
||||
func AddNamedMigration(packageName, filename string, up, down rockhopper.TransactionHandler) {
|
||||
if registeredGoMigrations == nil {
|
||||
registeredGoMigrations = make(map[registryKey]*rockhopper.Migration)
|
||||
}
|
||||
|
||||
v, err := rockhopper.FileNumericComponent(filename)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("unable to parse numeric component from filename %s: %v", filename, err))
|
||||
|
@ -91,7 +82,7 @@ func AddNamedMigration(packageName, filename string, up, down rockhopper.Transac
|
|||
UseTx: true,
|
||||
}
|
||||
|
||||
key := registryKey{Package: packageName, Version: v}
|
||||
key := rockhopper.RegistryKey{Package: packageName, Version: v}
|
||||
if existing, ok := registeredGoMigrations[key]; ok {
|
||||
panic(fmt.Sprintf("failed to add migration %q: version conflicts with key %+v: %+v", filename, key, existing))
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ func TestGetMigrationsMap(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMergeMigrationsMap(t *testing.T) {
|
||||
MergeMigrationsMap(map[registryKey]*rockhopper.Migration{
|
||||
registryKey{Version: 2}: &rockhopper.Migration{},
|
||||
registryKey{Version: 2}: &rockhopper.Migration{},
|
||||
MergeMigrationsMap(map[rockhopper.RegistryKey]*rockhopper.Migration{
|
||||
rockhopper.RegistryKey{Version: 2}: &rockhopper.Migration{},
|
||||
rockhopper.RegistryKey{Version: 2}: &rockhopper.Migration{},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_trades, down_main_trades)
|
||||
|
||||
}
|
||||
|
||||
func up_main_trades(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_tradeIndex, down_main_tradeIndex)
|
||||
|
||||
}
|
||||
|
||||
func up_main_tradeIndex(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_orders, down_main_orders)
|
||||
|
||||
}
|
||||
|
||||
func up_main_orders(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_tradesAddOrderId, down_main_tradesAddOrderId)
|
||||
|
||||
}
|
||||
|
||||
func up_main_tradesAddOrderId(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_tradesIndexFix, down_main_tradesIndexFix)
|
||||
|
||||
}
|
||||
|
||||
func up_main_tradesIndexFix(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_ordersAddIndex, down_main_ordersAddIndex)
|
||||
|
||||
}
|
||||
|
||||
func up_main_ordersAddIndex(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_klines, down_main_klines)
|
||||
|
||||
}
|
||||
|
||||
func up_main_klines(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
package sqlite3
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/c9s/rockhopper/v2"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddMigration("main", up_main_fixSymbolLength, down_main_fixSymbolLength)
|
||||
|
||||
}
|
||||
|
||||
func up_main_fixSymbolLength(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
// This code is executed when the migration is applied.
|
||||
_, err = tx.ExecContext(ctx, "SELECT 1;")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func down_main_fixSymbolLength(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
// This code is executed when the migration is rolled back.
|
||||
_, err = tx.ExecContext(ctx, "SELECT 1;")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_fixUniqueIndex, down_main_fixUniqueIndex)
|
||||
|
||||
}
|
||||
|
||||
func up_main_fixUniqueIndex(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addMarginColumns, down_main_addMarginColumns)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addMarginColumns(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_tradePriceQuantityIndex, down_main_tradePriceQuantityIndex)
|
||||
|
||||
}
|
||||
|
||||
func up_main_tradePriceQuantityIndex(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addPnlColumn, down_main_addPnlColumn)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addPnlColumn(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addRewardsTable, down_main_addRewardsTable)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addRewardsTable(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addWithdrawsTable, down_main_addWithdrawsTable)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addWithdrawsTable(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addDepositsTable, down_main_addDepositsTable)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addDepositsTable(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addKlineTakerBuyColumns, down_main_addKlineTakerBuyColumns)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addKlineTakerBuyColumns(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addIsFuturesColumn, down_main_addIsFuturesColumn)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addIsFuturesColumn(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addFtxKline, down_main_addFtxKline)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addFtxKline(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addNavHistoryDetails, down_main_addNavHistoryDetails)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addNavHistoryDetails(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_updateFeeCurrencyLength, down_main_updateFeeCurrencyLength)
|
||||
|
||||
}
|
||||
|
||||
func up_main_updateFeeCurrencyLength(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addKucoinKlines, down_main_addKucoinKlines)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addKucoinKlines(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addProfitTable, down_main_addProfitTable)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addProfitTable(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addPositions, down_main_addPositions)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addPositions(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_fixTradeIndexes, down_main_fixTradeIndexes)
|
||||
|
||||
}
|
||||
|
||||
func up_main_fixTradeIndexes(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_fixFeeColumn, down_main_fixFeeColumn)
|
||||
|
||||
}
|
||||
|
||||
func up_main_fixFeeColumn(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addMarginInfoToNav, down_main_addMarginInfoToNav)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addMarginInfoToNav(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_fixNetAssetColumn, down_main_fixNetAssetColumn)
|
||||
|
||||
}
|
||||
|
||||
func up_main_fixNetAssetColumn(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_fixProfitSymbolLength, down_main_fixProfitSymbolLength)
|
||||
|
||||
}
|
||||
|
||||
func up_main_fixProfitSymbolLength(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_klineUniqueIdx, down_main_klineUniqueIdx)
|
||||
|
||||
}
|
||||
|
||||
func up_main_klineUniqueIdx(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_marginLoans, down_main_marginLoans)
|
||||
|
||||
}
|
||||
|
||||
func up_main_marginLoans(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_marginRepays, down_main_marginRepays)
|
||||
|
||||
}
|
||||
|
||||
func up_main_marginRepays(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_marginInterests, down_main_marginInterests)
|
||||
|
||||
}
|
||||
|
||||
func up_main_marginInterests(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_marginLiquidations, down_main_marginLiquidations)
|
||||
|
||||
}
|
||||
|
||||
func up_main_marginLiquidations(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_addBybitKlines, down_main_addBybitKlines)
|
||||
|
||||
}
|
||||
|
||||
func up_main_addBybitKlines(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
func init() {
|
||||
AddMigration("main", up_main_fixOrderStatusLength, down_main_fixOrderStatusLength)
|
||||
|
||||
}
|
||||
|
||||
func up_main_fixOrderStatusLength(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
|
|
|
@ -9,14 +9,9 @@ import (
|
|||
"github.com/c9s/rockhopper/v2"
|
||||
)
|
||||
|
||||
type registryKey struct {
|
||||
Package string
|
||||
Version int64
|
||||
}
|
||||
var registeredGoMigrations = map[rockhopper.RegistryKey]*rockhopper.Migration{}
|
||||
|
||||
var registeredGoMigrations = map[registryKey]*rockhopper.Migration{}
|
||||
|
||||
func MergeMigrationsMap(ms map[registryKey]*rockhopper.Migration) {
|
||||
func MergeMigrationsMap(ms map[rockhopper.RegistryKey]*rockhopper.Migration) {
|
||||
for k, m := range ms {
|
||||
if _, ok := registeredGoMigrations[k]; !ok {
|
||||
registeredGoMigrations[k] = m
|
||||
|
@ -26,7 +21,7 @@ func MergeMigrationsMap(ms map[registryKey]*rockhopper.Migration) {
|
|||
}
|
||||
}
|
||||
|
||||
func GetMigrationsMap() map[registryKey]*rockhopper.Migration {
|
||||
func GetMigrationsMap() map[rockhopper.RegistryKey]*rockhopper.Migration {
|
||||
return registeredGoMigrations
|
||||
}
|
||||
|
||||
|
@ -71,10 +66,6 @@ func _parseFuncPackageName(funcName string) string {
|
|||
|
||||
// AddNamedMigration adds a named migration to the registered go migration map
|
||||
func AddNamedMigration(packageName, filename string, up, down rockhopper.TransactionHandler) {
|
||||
if registeredGoMigrations == nil {
|
||||
registeredGoMigrations = make(map[registryKey]*rockhopper.Migration)
|
||||
}
|
||||
|
||||
v, err := rockhopper.FileNumericComponent(filename)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("unable to parse numeric component from filename %s: %v", filename, err))
|
||||
|
@ -91,7 +82,7 @@ func AddNamedMigration(packageName, filename string, up, down rockhopper.Transac
|
|||
UseTx: true,
|
||||
}
|
||||
|
||||
key := registryKey{Package: packageName, Version: v}
|
||||
key := rockhopper.RegistryKey{Package: packageName, Version: v}
|
||||
if existing, ok := registeredGoMigrations[key]; ok {
|
||||
panic(fmt.Sprintf("failed to add migration %q: version conflicts with key %+v: %+v", filename, key, existing))
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ func TestGetMigrationsMap(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMergeMigrationsMap(t *testing.T) {
|
||||
MergeMigrationsMap(map[registryKey]*rockhopper.Migration{
|
||||
registryKey{Version: 2}: &rockhopper.Migration{},
|
||||
registryKey{Version: 2}: &rockhopper.Migration{},
|
||||
MergeMigrationsMap(map[rockhopper.RegistryKey]*rockhopper.Migration{
|
||||
rockhopper.RegistryKey{Version: 2}: &rockhopper.Migration{},
|
||||
rockhopper.RegistryKey{Version: 2}: &rockhopper.Migration{},
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user