Skip to content

Commit

Permalink
compile and update migration package
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Jan 24, 2024
1 parent c7027db commit ee1a272
Show file tree
Hide file tree
Showing 77 changed files with 18 additions and 138 deletions.
1 change: 0 additions & 1 deletion pkg/migrations/mysql/main_20200721225616_trades.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion pkg/migrations/mysql/main_20200819054742_trade_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion pkg/migrations/mysql/main_20201102222546_orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion pkg/migrations/mysql/main_20201106114742_klines.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion pkg/migrations/mysql/main_20210215203116_add_pnl_column.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion pkg/migrations/mysql/main_20211211020303_add_ftx_kline.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion pkg/migrations/mysql/main_20220307132917_add_positions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion pkg/migrations/mysql/main_20220419121046_fix_fee_column.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion pkg/migrations/mysql/main_20220531012226_margin_loans.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion pkg/migrations/mysql/main_20220531013327_margin_repays.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
17 changes: 4 additions & 13 deletions pkg/migrations/mysql/migration_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ import (
"github.com/c9s/rockhopper/v2"
)

type registryKey struct {
Package string
Version int64
}

var registeredGoMigrations = map[registryKey]*rockhopper.Migration{}
var registeredGoMigrations = map[rockhopper.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
Expand All @@ -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
}

Expand Down Expand Up @@ -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))
Expand All @@ -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))
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/migrations/mysql/migration_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},

Check failure on line 18 in pkg/migrations/mysql/migration_api_test.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofmt`-ed with `-s` (gofmt)
rockhopper.RegistryKey{Version: 2}: &rockhopper.Migration{},
})
}
1 change: 0 additions & 1 deletion pkg/migrations/sqlite3/main_20200721225616_trades.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion pkg/migrations/sqlite3/main_20200819054742_trade_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion pkg/migrations/sqlite3/main_20201102222546_orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit ee1a272

Please sign in to comment.