From ee1a2727f65a9d4a464dc6b4bebcb200befa5992 Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 24 Jan 2024 15:56:04 +0800 Subject: [PATCH] compile and update migration package --- .../mysql/main_20200721225616_trades.go | 1 - .../mysql/main_20200819054742_trade_index.go | 1 - .../mysql/main_20201102222546_orders.go | 1 - ...main_20201103173342_trades_add_order_id.go | 1 - .../main_20201105092857_trades_index_fix.go | 1 - .../main_20201105093056_orders_add_index.go | 1 - .../mysql/main_20201106114742_klines.go | 1 - .../main_20201211175751_fix_symbol_length.go | 1 - .../main_20210118163847_fix_unique_index.go | 1 - .../main_20210119232826_add_margin_columns.go | 1 - ...210129182704_trade_price_quantity_index.go | 1 - .../main_20210215203116_add_pnl_column.go | 1 - .../main_20210223080622_add_rewards_table.go | 1 - ...main_20210301140656_add_withdraws_table.go | 1 - .../main_20210307201830_add_deposits_table.go | 1 - ...ain_20210416230730_klines_symbol_length.go | 1 - ...n_20210421091430_increase_symbol_length.go | 1 - ..._20210421095030_increase_decimal_length.go | 1 - ...10531234123_add_kline_taker_buy_columns.go | 1 - ...in_20211205162043_add_is_futures_column.go | 1 - .../main_20211211020303_add_ftx_kline.go | 1 - ..._20211211034819_add_nav_history_details.go | 1 - ...211211103657_update_fee_currency_length.go | 1 - .../main_20211226022411_add_kucoin_klines.go | 1 - .../main_20220304153317_add_profit_table.go | 1 - .../main_20220307132917_add_positions.go | 1 - .../main_20220317125555_fix_trade_indexes.go | 1 - .../main_20220419121046_fix_fee_column.go | 1 - ...n_20220503144849_add_margin_info_to_nav.go | 1 - ...ain_20220504184155_fix_net_asset_column.go | 1 - ...20220512170322_fix_profit_symbol_length.go | 1 - .../main_20220520140707_kline_unique_idx.go | 1 - .../mysql/main_20220531012226_margin_loans.go | 1 - .../main_20220531013327_margin_repays.go | 1 - .../main_20220531013542_margin_interests.go | 1 - ...main_20220531015005_margin_liquidations.go | 1 - .../main_20230815173104_add_bybit_klines.go | 1 - ..._20231123125402_fix_order_status_length.go | 1 - pkg/migrations/mysql/migration_api.go | 17 +++-------- pkg/migrations/mysql/migration_api_test.go | 6 ++-- .../sqlite3/main_20200721225616_trades.go | 1 - .../main_20200819054742_trade_index.go | 1 - .../sqlite3/main_20201102222546_orders.go | 1 - ...main_20201103173342_trades_add_order_id.go | 1 - .../main_20201105092857_trades_index_fix.go | 1 - .../main_20201105093056_orders_add_index.go | 1 - .../sqlite3/main_20201106114742_klines.go | 9 +++--- .../main_20201211175751_fix_symbol_length.go | 30 ------------------- .../main_20210118163847_fix_unique_index.go | 1 - .../main_20210119232826_add_margin_columns.go | 1 - ...210129182704_trade_price_quantity_index.go | 1 - .../main_20210215203111_add_pnl_column.go | 1 - .../main_20210223080622_add_rewards_table.go | 1 - ...main_20210301140656_add_withdraws_table.go | 1 - .../main_20210307201830_add_deposits_table.go | 1 - ...10531234123_add_kline_taker_buy_columns.go | 1 - ...in_20211205162302_add_is_futures_column.go | 1 - .../main_20211211020303_add_ftx_kline.go | 1 - ..._20211211034818_add_nav_history_details.go | 1 - ...211211103657_update_fee_currency_length.go | 1 - .../main_20211226022411_add_kucoin_klines.go | 1 - .../main_20220304153309_add_profit_table.go | 1 - .../main_20220307132917_add_positions.go | 1 - .../main_20220317125555_fix_trade_indexes.go | 1 - .../main_20220419121046_fix_fee_column.go | 1 - ...n_20220503144849_add_margin_info_to_nav.go | 1 - ...ain_20220504184155_fix_net_asset_column.go | 1 - ...20220512170330_fix_profit_symbol_length.go | 1 - .../main_20220520140707_kline_unique_idx.go | 1 - .../main_20220531012226_margin_loans.go | 1 - .../main_20220531013327_margin_repays.go | 1 - .../main_20220531013541_margin_interests.go | 1 - ...main_20220531015005_margin_liquidations.go | 1 - .../main_20230815173104_add_bybit_klines.go | 1 - ..._20231123125402_fix_order_status_length.go | 1 - pkg/migrations/sqlite3/migration_api.go | 17 +++-------- pkg/migrations/sqlite3/migration_api_test.go | 6 ++-- 77 files changed, 18 insertions(+), 138 deletions(-) delete mode 100644 pkg/migrations/sqlite3/main_20201211175751_fix_symbol_length.go diff --git a/pkg/migrations/mysql/main_20200721225616_trades.go b/pkg/migrations/mysql/main_20200721225616_trades.go index 7d07aa5fb..bc01d80b1 100644 --- a/pkg/migrations/mysql/main_20200721225616_trades.go +++ b/pkg/migrations/mysql/main_20200721225616_trades.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20200819054742_trade_index.go b/pkg/migrations/mysql/main_20200819054742_trade_index.go index 0ae23b361..fbdeee0c8 100644 --- a/pkg/migrations/mysql/main_20200819054742_trade_index.go +++ b/pkg/migrations/mysql/main_20200819054742_trade_index.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20201102222546_orders.go b/pkg/migrations/mysql/main_20201102222546_orders.go index 59af3bfb0..0025dabb0 100644 --- a/pkg/migrations/mysql/main_20201102222546_orders.go +++ b/pkg/migrations/mysql/main_20201102222546_orders.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20201103173342_trades_add_order_id.go b/pkg/migrations/mysql/main_20201103173342_trades_add_order_id.go index 318066f3e..50417a33c 100644 --- a/pkg/migrations/mysql/main_20201103173342_trades_add_order_id.go +++ b/pkg/migrations/mysql/main_20201103173342_trades_add_order_id.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20201105092857_trades_index_fix.go b/pkg/migrations/mysql/main_20201105092857_trades_index_fix.go index 358942917..a1a8440dc 100644 --- a/pkg/migrations/mysql/main_20201105092857_trades_index_fix.go +++ b/pkg/migrations/mysql/main_20201105092857_trades_index_fix.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20201105093056_orders_add_index.go b/pkg/migrations/mysql/main_20201105093056_orders_add_index.go index 19681e4b4..4d39739de 100644 --- a/pkg/migrations/mysql/main_20201105093056_orders_add_index.go +++ b/pkg/migrations/mysql/main_20201105093056_orders_add_index.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20201106114742_klines.go b/pkg/migrations/mysql/main_20201106114742_klines.go index 18b229073..ca02f0c62 100644 --- a/pkg/migrations/mysql/main_20201106114742_klines.go +++ b/pkg/migrations/mysql/main_20201106114742_klines.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20201211175751_fix_symbol_length.go b/pkg/migrations/mysql/main_20201211175751_fix_symbol_length.go index 88be892d2..7e8c57cf4 100644 --- a/pkg/migrations/mysql/main_20201211175751_fix_symbol_length.go +++ b/pkg/migrations/mysql/main_20201211175751_fix_symbol_length.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20210118163847_fix_unique_index.go b/pkg/migrations/mysql/main_20210118163847_fix_unique_index.go index c1573ac93..f4b9d7b2d 100644 --- a/pkg/migrations/mysql/main_20210118163847_fix_unique_index.go +++ b/pkg/migrations/mysql/main_20210118163847_fix_unique_index.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20210119232826_add_margin_columns.go b/pkg/migrations/mysql/main_20210119232826_add_margin_columns.go index b624b8158..2c8bf8575 100644 --- a/pkg/migrations/mysql/main_20210119232826_add_margin_columns.go +++ b/pkg/migrations/mysql/main_20210119232826_add_margin_columns.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20210129182704_trade_price_quantity_index.go b/pkg/migrations/mysql/main_20210129182704_trade_price_quantity_index.go index 9ff09a78a..adf3ebad8 100644 --- a/pkg/migrations/mysql/main_20210129182704_trade_price_quantity_index.go +++ b/pkg/migrations/mysql/main_20210129182704_trade_price_quantity_index.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20210215203116_add_pnl_column.go b/pkg/migrations/mysql/main_20210215203116_add_pnl_column.go index 831d79d1d..b9c1b88fa 100644 --- a/pkg/migrations/mysql/main_20210215203116_add_pnl_column.go +++ b/pkg/migrations/mysql/main_20210215203116_add_pnl_column.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20210223080622_add_rewards_table.go b/pkg/migrations/mysql/main_20210223080622_add_rewards_table.go index 06652355c..0468944e1 100644 --- a/pkg/migrations/mysql/main_20210223080622_add_rewards_table.go +++ b/pkg/migrations/mysql/main_20210223080622_add_rewards_table.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20210301140656_add_withdraws_table.go b/pkg/migrations/mysql/main_20210301140656_add_withdraws_table.go index 402aab3ec..6b2d2fcee 100644 --- a/pkg/migrations/mysql/main_20210301140656_add_withdraws_table.go +++ b/pkg/migrations/mysql/main_20210301140656_add_withdraws_table.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20210307201830_add_deposits_table.go b/pkg/migrations/mysql/main_20210307201830_add_deposits_table.go index 35e9a59da..b5264e2e5 100644 --- a/pkg/migrations/mysql/main_20210307201830_add_deposits_table.go +++ b/pkg/migrations/mysql/main_20210307201830_add_deposits_table.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20210416230730_klines_symbol_length.go b/pkg/migrations/mysql/main_20210416230730_klines_symbol_length.go index ab818858a..3a0584e7c 100644 --- a/pkg/migrations/mysql/main_20210416230730_klines_symbol_length.go +++ b/pkg/migrations/mysql/main_20210416230730_klines_symbol_length.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20210421091430_increase_symbol_length.go b/pkg/migrations/mysql/main_20210421091430_increase_symbol_length.go index f3f19fe41..d7a1cc6d1 100644 --- a/pkg/migrations/mysql/main_20210421091430_increase_symbol_length.go +++ b/pkg/migrations/mysql/main_20210421091430_increase_symbol_length.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20210421095030_increase_decimal_length.go b/pkg/migrations/mysql/main_20210421095030_increase_decimal_length.go index 141599d4e..6e054115b 100644 --- a/pkg/migrations/mysql/main_20210421095030_increase_decimal_length.go +++ b/pkg/migrations/mysql/main_20210421095030_increase_decimal_length.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20210531234123_add_kline_taker_buy_columns.go b/pkg/migrations/mysql/main_20210531234123_add_kline_taker_buy_columns.go index 47af2b54c..f343b5b64 100644 --- a/pkg/migrations/mysql/main_20210531234123_add_kline_taker_buy_columns.go +++ b/pkg/migrations/mysql/main_20210531234123_add_kline_taker_buy_columns.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20211205162043_add_is_futures_column.go b/pkg/migrations/mysql/main_20211205162043_add_is_futures_column.go index d9b85ce25..b6f683256 100644 --- a/pkg/migrations/mysql/main_20211205162043_add_is_futures_column.go +++ b/pkg/migrations/mysql/main_20211205162043_add_is_futures_column.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20211211020303_add_ftx_kline.go b/pkg/migrations/mysql/main_20211211020303_add_ftx_kline.go index 0ef496467..a4be4ef14 100644 --- a/pkg/migrations/mysql/main_20211211020303_add_ftx_kline.go +++ b/pkg/migrations/mysql/main_20211211020303_add_ftx_kline.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20211211034819_add_nav_history_details.go b/pkg/migrations/mysql/main_20211211034819_add_nav_history_details.go index f8740b452..db6d50806 100644 --- a/pkg/migrations/mysql/main_20211211034819_add_nav_history_details.go +++ b/pkg/migrations/mysql/main_20211211034819_add_nav_history_details.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20211211103657_update_fee_currency_length.go b/pkg/migrations/mysql/main_20211211103657_update_fee_currency_length.go index 998206a4d..6d56e93f0 100644 --- a/pkg/migrations/mysql/main_20211211103657_update_fee_currency_length.go +++ b/pkg/migrations/mysql/main_20211211103657_update_fee_currency_length.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20211226022411_add_kucoin_klines.go b/pkg/migrations/mysql/main_20211226022411_add_kucoin_klines.go index 97cfb617f..f09a1fc1f 100644 --- a/pkg/migrations/mysql/main_20211226022411_add_kucoin_klines.go +++ b/pkg/migrations/mysql/main_20211226022411_add_kucoin_klines.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20220304153317_add_profit_table.go b/pkg/migrations/mysql/main_20220304153317_add_profit_table.go index 08c4b1018..43d1b0bae 100644 --- a/pkg/migrations/mysql/main_20220304153317_add_profit_table.go +++ b/pkg/migrations/mysql/main_20220304153317_add_profit_table.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20220307132917_add_positions.go b/pkg/migrations/mysql/main_20220307132917_add_positions.go index 700fde1d7..51fa78570 100644 --- a/pkg/migrations/mysql/main_20220307132917_add_positions.go +++ b/pkg/migrations/mysql/main_20220307132917_add_positions.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20220317125555_fix_trade_indexes.go b/pkg/migrations/mysql/main_20220317125555_fix_trade_indexes.go index 23aaf3f10..ea8bfc879 100644 --- a/pkg/migrations/mysql/main_20220317125555_fix_trade_indexes.go +++ b/pkg/migrations/mysql/main_20220317125555_fix_trade_indexes.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20220419121046_fix_fee_column.go b/pkg/migrations/mysql/main_20220419121046_fix_fee_column.go index 912816eca..adf2d3833 100644 --- a/pkg/migrations/mysql/main_20220419121046_fix_fee_column.go +++ b/pkg/migrations/mysql/main_20220419121046_fix_fee_column.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20220503144849_add_margin_info_to_nav.go b/pkg/migrations/mysql/main_20220503144849_add_margin_info_to_nav.go index 8298ab0c4..49deefacc 100644 --- a/pkg/migrations/mysql/main_20220503144849_add_margin_info_to_nav.go +++ b/pkg/migrations/mysql/main_20220503144849_add_margin_info_to_nav.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20220504184155_fix_net_asset_column.go b/pkg/migrations/mysql/main_20220504184155_fix_net_asset_column.go index b284a023c..ed4344b3c 100644 --- a/pkg/migrations/mysql/main_20220504184155_fix_net_asset_column.go +++ b/pkg/migrations/mysql/main_20220504184155_fix_net_asset_column.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20220512170322_fix_profit_symbol_length.go b/pkg/migrations/mysql/main_20220512170322_fix_profit_symbol_length.go index 668ac1f5b..90166fe7d 100644 --- a/pkg/migrations/mysql/main_20220512170322_fix_profit_symbol_length.go +++ b/pkg/migrations/mysql/main_20220512170322_fix_profit_symbol_length.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20220520140707_kline_unique_idx.go b/pkg/migrations/mysql/main_20220520140707_kline_unique_idx.go index 98b801ba0..0ef364440 100644 --- a/pkg/migrations/mysql/main_20220520140707_kline_unique_idx.go +++ b/pkg/migrations/mysql/main_20220520140707_kline_unique_idx.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20220531012226_margin_loans.go b/pkg/migrations/mysql/main_20220531012226_margin_loans.go index c752e2747..68fe149d5 100644 --- a/pkg/migrations/mysql/main_20220531012226_margin_loans.go +++ b/pkg/migrations/mysql/main_20220531012226_margin_loans.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20220531013327_margin_repays.go b/pkg/migrations/mysql/main_20220531013327_margin_repays.go index fc7435f10..97ce51243 100644 --- a/pkg/migrations/mysql/main_20220531013327_margin_repays.go +++ b/pkg/migrations/mysql/main_20220531013327_margin_repays.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20220531013542_margin_interests.go b/pkg/migrations/mysql/main_20220531013542_margin_interests.go index ebf15cabb..f42f60dd8 100644 --- a/pkg/migrations/mysql/main_20220531013542_margin_interests.go +++ b/pkg/migrations/mysql/main_20220531013542_margin_interests.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20220531015005_margin_liquidations.go b/pkg/migrations/mysql/main_20220531015005_margin_liquidations.go index 3bd3aaa2c..dbdfafc8d 100644 --- a/pkg/migrations/mysql/main_20220531015005_margin_liquidations.go +++ b/pkg/migrations/mysql/main_20220531015005_margin_liquidations.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20230815173104_add_bybit_klines.go b/pkg/migrations/mysql/main_20230815173104_add_bybit_klines.go index 67e6dcb67..47897cbab 100644 --- a/pkg/migrations/mysql/main_20230815173104_add_bybit_klines.go +++ b/pkg/migrations/mysql/main_20230815173104_add_bybit_klines.go @@ -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) { diff --git a/pkg/migrations/mysql/main_20231123125402_fix_order_status_length.go b/pkg/migrations/mysql/main_20231123125402_fix_order_status_length.go index 3be1c57bf..ef9c57f8d 100644 --- a/pkg/migrations/mysql/main_20231123125402_fix_order_status_length.go +++ b/pkg/migrations/mysql/main_20231123125402_fix_order_status_length.go @@ -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) { diff --git a/pkg/migrations/mysql/migration_api.go b/pkg/migrations/mysql/migration_api.go index 04311c1cc..95c14a5ce 100644 --- a/pkg/migrations/mysql/migration_api.go +++ b/pkg/migrations/mysql/migration_api.go @@ -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)) } diff --git a/pkg/migrations/mysql/migration_api_test.go b/pkg/migrations/mysql/migration_api_test.go index 36f387b44..4e5154ebf 100644 --- a/pkg/migrations/mysql/migration_api_test.go +++ b/pkg/migrations/mysql/migration_api_test.go @@ -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{}, }) } diff --git a/pkg/migrations/sqlite3/main_20200721225616_trades.go b/pkg/migrations/sqlite3/main_20200721225616_trades.go index 8903aaab6..150034671 100644 --- a/pkg/migrations/sqlite3/main_20200721225616_trades.go +++ b/pkg/migrations/sqlite3/main_20200721225616_trades.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20200819054742_trade_index.go b/pkg/migrations/sqlite3/main_20200819054742_trade_index.go index f1fe76da6..289e2adc2 100644 --- a/pkg/migrations/sqlite3/main_20200819054742_trade_index.go +++ b/pkg/migrations/sqlite3/main_20200819054742_trade_index.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20201102222546_orders.go b/pkg/migrations/sqlite3/main_20201102222546_orders.go index 50fea710f..6bf028862 100644 --- a/pkg/migrations/sqlite3/main_20201102222546_orders.go +++ b/pkg/migrations/sqlite3/main_20201102222546_orders.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20201103173342_trades_add_order_id.go b/pkg/migrations/sqlite3/main_20201103173342_trades_add_order_id.go index 7cdbf2dc7..ad12444ae 100644 --- a/pkg/migrations/sqlite3/main_20201103173342_trades_add_order_id.go +++ b/pkg/migrations/sqlite3/main_20201103173342_trades_add_order_id.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20201105092857_trades_index_fix.go b/pkg/migrations/sqlite3/main_20201105092857_trades_index_fix.go index 6b3a133b1..ae15782c8 100644 --- a/pkg/migrations/sqlite3/main_20201105092857_trades_index_fix.go +++ b/pkg/migrations/sqlite3/main_20201105092857_trades_index_fix.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20201105093056_orders_add_index.go b/pkg/migrations/sqlite3/main_20201105093056_orders_add_index.go index ae5df7bd9..f826aa247 100644 --- a/pkg/migrations/sqlite3/main_20201105093056_orders_add_index.go +++ b/pkg/migrations/sqlite3/main_20201105093056_orders_add_index.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20201106114742_klines.go b/pkg/migrations/sqlite3/main_20201106114742_klines.go index 801071948..a1d99601b 100644 --- a/pkg/migrations/sqlite3/main_20201106114742_klines.go +++ b/pkg/migrations/sqlite3/main_20201106114742_klines.go @@ -8,24 +8,23 @@ import ( func init() { AddMigration("main", up_main_klines, down_main_klines) - } func up_main_klines(ctx context.Context, tx rockhopper.SQLExecutor) (err error) { // This code is executed when the migration is applied. - _, err = tx.ExecContext(ctx, "CREATE TABLE `klines`\n(\n `gid` INTEGER PRIMARY KEY AUTOINCREMENT,\n `exchange` VARCHAR(10) NOT NULL,\n `start_time` DATETIME(3) NOT NULL,\n `end_time` DATETIME(3) NOT NULL,\n `interval` VARCHAR(3) NOT NULL,\n `symbol` VARCHAR(7) NOT NULL,\n `open` DECIMAL(16, 8) NOT NULL,\n `high` DECIMAL(16, 8) NOT NULL,\n `low` DECIMAL(16, 8) NOT NULL,\n `close` DECIMAL(16, 8) NOT NULL DEFAULT 0.0,\n `volume` DECIMAL(16, 8) NOT NULL DEFAULT 0.0,\n `closed` BOOLEAN NOT NULL DEFAULT TRUE,\n `last_trade_id` INT NOT NULL DEFAULT 0,\n `num_trades` INT NOT NULL DEFAULT 0\n);") + _, err = tx.ExecContext(ctx, "CREATE TABLE `klines`\n(\n `gid` INTEGER PRIMARY KEY AUTOINCREMENT,\n `exchange` VARCHAR(10) NOT NULL,\n `start_time` DATETIME(3) NOT NULL,\n `end_time` DATETIME(3) NOT NULL,\n `interval` VARCHAR(3) NOT NULL,\n `symbol` VARCHAR(7) NOT NULL,\n `open` DECIMAL(16, 8) NOT NULL,\n `high` DECIMAL(16, 8) NOT NULL,\n `low` DECIMAL(16, 8) NOT NULL,\n `close` DECIMAL(16, 8) NOT NULL DEFAULT 0.0,\n `volume` DECIMAL(16, 8) NOT NULL DEFAULT 0.0,\n `closed` BOOLEAN NOT NULL DEFAULT TRUE,\n `last_trade_id` INT NOT NULL DEFAULT 0,\n `num_trades` INT NOT NULL DEFAULT 0\n);") if err != nil { return err } - _, err = tx.ExecContext(ctx, "CREATE TABLE `okex_klines`\n(\n `gid` INTEGER PRIMARY KEY AUTOINCREMENT,\n `exchange` VARCHAR(10) NOT NULL,\n `start_time` DATETIME(3) NOT NULL,\n `end_time` DATETIME(3) NOT NULL,\n `interval` VARCHAR(3) NOT NULL,\n `symbol` VARCHAR(7) NOT NULL,\n `open` DECIMAL(16, 8) NOT NULL,\n `high` DECIMAL(16, 8) NOT NULL,\n `low` DECIMAL(16, 8) NOT NULL,\n `close` DECIMAL(16, 8) NOT NULL DEFAULT 0.0,\n `volume` DECIMAL(16, 8) NOT NULL DEFAULT 0.0,\n `closed` BOOLEAN NOT NULL DEFAULT TRUE,\n `last_trade_id` INT NOT NULL DEFAULT 0,\n `num_trades` INT NOT NULL DEFAULT 0\n);") + _, err = tx.ExecContext(ctx, "CREATE TABLE `okex_klines`\n(\n `gid` INTEGER PRIMARY KEY AUTOINCREMENT,\n `exchange` VARCHAR(10) NOT NULL,\n `start_time` DATETIME(3) NOT NULL,\n `end_time` DATETIME(3) NOT NULL,\n `interval` VARCHAR(3) NOT NULL,\n `symbol` VARCHAR(7) NOT NULL,\n `open` DECIMAL(16, 8) NOT NULL,\n `high` DECIMAL(16, 8) NOT NULL,\n `low` DECIMAL(16, 8) NOT NULL,\n `close` DECIMAL(16, 8) NOT NULL DEFAULT 0.0,\n `volume` DECIMAL(16, 8) NOT NULL DEFAULT 0.0,\n `closed` BOOLEAN NOT NULL DEFAULT TRUE,\n `last_trade_id` INT NOT NULL DEFAULT 0,\n `num_trades` INT NOT NULL DEFAULT 0\n);") if err != nil { return err } - _, err = tx.ExecContext(ctx, "CREATE TABLE `binance_klines`\n(\n `gid` INTEGER PRIMARY KEY AUTOINCREMENT,\n `exchange` VARCHAR(10) NOT NULL,\n `start_time` DATETIME(3) NOT NULL,\n `end_time` DATETIME(3) NOT NULL,\n `interval` VARCHAR(3) NOT NULL,\n `symbol` VARCHAR(7) NOT NULL,\n `open` DECIMAL(16, 8) NOT NULL,\n `high` DECIMAL(16, 8) NOT NULL,\n `low` DECIMAL(16, 8) NOT NULL,\n `close` DECIMAL(16, 8) NOT NULL DEFAULT 0.0,\n `volume` DECIMAL(16, 8) NOT NULL DEFAULT 0.0,\n `closed` BOOLEAN NOT NULL DEFAULT TRUE,\n `last_trade_id` INT NOT NULL DEFAULT 0,\n `num_trades` INT NOT NULL DEFAULT 0\n);") + _, err = tx.ExecContext(ctx, "CREATE TABLE `binance_klines`\n(\n `gid` INTEGER PRIMARY KEY AUTOINCREMENT,\n `exchange` VARCHAR(10) NOT NULL,\n `start_time` DATETIME(3) NOT NULL,\n `end_time` DATETIME(3) NOT NULL,\n `interval` VARCHAR(3) NOT NULL,\n `symbol` VARCHAR(7) NOT NULL,\n `open` DECIMAL(16, 8) NOT NULL,\n `high` DECIMAL(16, 8) NOT NULL,\n `low` DECIMAL(16, 8) NOT NULL,\n `close` DECIMAL(16, 8) NOT NULL DEFAULT 0.0,\n `volume` DECIMAL(16, 8) NOT NULL DEFAULT 0.0,\n `closed` BOOLEAN NOT NULL DEFAULT TRUE,\n `last_trade_id` INT NOT NULL DEFAULT 0,\n `num_trades` INT NOT NULL DEFAULT 0\n);") if err != nil { return err } - _, err = tx.ExecContext(ctx, "CREATE TABLE `max_klines`\n(\n `gid` INTEGER PRIMARY KEY AUTOINCREMENT,\n `exchange` VARCHAR(10) NOT NULL,\n `start_time` DATETIME(3) NOT NULL,\n `end_time` DATETIME(3) NOT NULL,\n `interval` VARCHAR(3) NOT NULL,\n `symbol` VARCHAR(7) NOT NULL,\n `open` DECIMAL(16, 8) NOT NULL,\n `high` DECIMAL(16, 8) NOT NULL,\n `low` DECIMAL(16, 8) NOT NULL,\n `close` DECIMAL(16, 8) NOT NULL DEFAULT 0.0,\n `volume` DECIMAL(16, 8) NOT NULL DEFAULT 0.0,\n `closed` BOOLEAN NOT NULL DEFAULT TRUE,\n `last_trade_id` INT NOT NULL DEFAULT 0,\n `num_trades` INT NOT NULL DEFAULT 0\n);") + _, err = tx.ExecContext(ctx, "CREATE TABLE `max_klines`\n(\n `gid` INTEGER PRIMARY KEY AUTOINCREMENT,\n `exchange` VARCHAR(10) NOT NULL,\n `start_time` DATETIME(3) NOT NULL,\n `end_time` DATETIME(3) NOT NULL,\n `interval` VARCHAR(3) NOT NULL,\n `symbol` VARCHAR(7) NOT NULL,\n `open` DECIMAL(16, 8) NOT NULL,\n `high` DECIMAL(16, 8) NOT NULL,\n `low` DECIMAL(16, 8) NOT NULL,\n `close` DECIMAL(16, 8) NOT NULL DEFAULT 0.0,\n `volume` DECIMAL(16, 8) NOT NULL DEFAULT 0.0,\n `closed` BOOLEAN NOT NULL DEFAULT TRUE,\n `last_trade_id` INT NOT NULL DEFAULT 0,\n `num_trades` INT NOT NULL DEFAULT 0\n);") if err != nil { return err } diff --git a/pkg/migrations/sqlite3/main_20201211175751_fix_symbol_length.go b/pkg/migrations/sqlite3/main_20201211175751_fix_symbol_length.go deleted file mode 100644 index ec208a3ec..000000000 --- a/pkg/migrations/sqlite3/main_20201211175751_fix_symbol_length.go +++ /dev/null @@ -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 -} diff --git a/pkg/migrations/sqlite3/main_20210118163847_fix_unique_index.go b/pkg/migrations/sqlite3/main_20210118163847_fix_unique_index.go index e1140c573..42fc0fd02 100644 --- a/pkg/migrations/sqlite3/main_20210118163847_fix_unique_index.go +++ b/pkg/migrations/sqlite3/main_20210118163847_fix_unique_index.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20210119232826_add_margin_columns.go b/pkg/migrations/sqlite3/main_20210119232826_add_margin_columns.go index 5a240ec9f..945efbb61 100644 --- a/pkg/migrations/sqlite3/main_20210119232826_add_margin_columns.go +++ b/pkg/migrations/sqlite3/main_20210119232826_add_margin_columns.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20210129182704_trade_price_quantity_index.go b/pkg/migrations/sqlite3/main_20210129182704_trade_price_quantity_index.go index b1a2d0b59..faa0854f4 100644 --- a/pkg/migrations/sqlite3/main_20210129182704_trade_price_quantity_index.go +++ b/pkg/migrations/sqlite3/main_20210129182704_trade_price_quantity_index.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20210215203111_add_pnl_column.go b/pkg/migrations/sqlite3/main_20210215203111_add_pnl_column.go index 71edce5a7..303d6b42a 100644 --- a/pkg/migrations/sqlite3/main_20210215203111_add_pnl_column.go +++ b/pkg/migrations/sqlite3/main_20210215203111_add_pnl_column.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20210223080622_add_rewards_table.go b/pkg/migrations/sqlite3/main_20210223080622_add_rewards_table.go index 2fdd3f4a5..f146d729c 100644 --- a/pkg/migrations/sqlite3/main_20210223080622_add_rewards_table.go +++ b/pkg/migrations/sqlite3/main_20210223080622_add_rewards_table.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20210301140656_add_withdraws_table.go b/pkg/migrations/sqlite3/main_20210301140656_add_withdraws_table.go index e159bcf5a..ed87cca69 100644 --- a/pkg/migrations/sqlite3/main_20210301140656_add_withdraws_table.go +++ b/pkg/migrations/sqlite3/main_20210301140656_add_withdraws_table.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20210307201830_add_deposits_table.go b/pkg/migrations/sqlite3/main_20210307201830_add_deposits_table.go index 2956724b9..a72225c10 100644 --- a/pkg/migrations/sqlite3/main_20210307201830_add_deposits_table.go +++ b/pkg/migrations/sqlite3/main_20210307201830_add_deposits_table.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20210531234123_add_kline_taker_buy_columns.go b/pkg/migrations/sqlite3/main_20210531234123_add_kline_taker_buy_columns.go index 862fd11b5..27a76d360 100644 --- a/pkg/migrations/sqlite3/main_20210531234123_add_kline_taker_buy_columns.go +++ b/pkg/migrations/sqlite3/main_20210531234123_add_kline_taker_buy_columns.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20211205162302_add_is_futures_column.go b/pkg/migrations/sqlite3/main_20211205162302_add_is_futures_column.go index 51f538a90..53c7568c3 100644 --- a/pkg/migrations/sqlite3/main_20211205162302_add_is_futures_column.go +++ b/pkg/migrations/sqlite3/main_20211205162302_add_is_futures_column.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20211211020303_add_ftx_kline.go b/pkg/migrations/sqlite3/main_20211211020303_add_ftx_kline.go index bf811ef90..e1328001c 100644 --- a/pkg/migrations/sqlite3/main_20211211020303_add_ftx_kline.go +++ b/pkg/migrations/sqlite3/main_20211211020303_add_ftx_kline.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20211211034818_add_nav_history_details.go b/pkg/migrations/sqlite3/main_20211211034818_add_nav_history_details.go index e1d34ad84..4639ce5b8 100644 --- a/pkg/migrations/sqlite3/main_20211211034818_add_nav_history_details.go +++ b/pkg/migrations/sqlite3/main_20211211034818_add_nav_history_details.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20211211103657_update_fee_currency_length.go b/pkg/migrations/sqlite3/main_20211211103657_update_fee_currency_length.go index 92cace767..8f346ee2c 100644 --- a/pkg/migrations/sqlite3/main_20211211103657_update_fee_currency_length.go +++ b/pkg/migrations/sqlite3/main_20211211103657_update_fee_currency_length.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20211226022411_add_kucoin_klines.go b/pkg/migrations/sqlite3/main_20211226022411_add_kucoin_klines.go index a3c67fe23..9fe9bd590 100644 --- a/pkg/migrations/sqlite3/main_20211226022411_add_kucoin_klines.go +++ b/pkg/migrations/sqlite3/main_20211226022411_add_kucoin_klines.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20220304153309_add_profit_table.go b/pkg/migrations/sqlite3/main_20220304153309_add_profit_table.go index ea1abac0b..560ab118d 100644 --- a/pkg/migrations/sqlite3/main_20220304153309_add_profit_table.go +++ b/pkg/migrations/sqlite3/main_20220304153309_add_profit_table.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20220307132917_add_positions.go b/pkg/migrations/sqlite3/main_20220307132917_add_positions.go index bf2a48bb5..87a5ad2d1 100644 --- a/pkg/migrations/sqlite3/main_20220307132917_add_positions.go +++ b/pkg/migrations/sqlite3/main_20220307132917_add_positions.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20220317125555_fix_trade_indexes.go b/pkg/migrations/sqlite3/main_20220317125555_fix_trade_indexes.go index e93c01fee..6e08a1089 100644 --- a/pkg/migrations/sqlite3/main_20220317125555_fix_trade_indexes.go +++ b/pkg/migrations/sqlite3/main_20220317125555_fix_trade_indexes.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20220419121046_fix_fee_column.go b/pkg/migrations/sqlite3/main_20220419121046_fix_fee_column.go index ee7548579..f190db6a6 100644 --- a/pkg/migrations/sqlite3/main_20220419121046_fix_fee_column.go +++ b/pkg/migrations/sqlite3/main_20220419121046_fix_fee_column.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20220503144849_add_margin_info_to_nav.go b/pkg/migrations/sqlite3/main_20220503144849_add_margin_info_to_nav.go index d0309bb6a..ca25e9ede 100644 --- a/pkg/migrations/sqlite3/main_20220503144849_add_margin_info_to_nav.go +++ b/pkg/migrations/sqlite3/main_20220503144849_add_margin_info_to_nav.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20220504184155_fix_net_asset_column.go b/pkg/migrations/sqlite3/main_20220504184155_fix_net_asset_column.go index 4850a7973..996a5cfd7 100644 --- a/pkg/migrations/sqlite3/main_20220504184155_fix_net_asset_column.go +++ b/pkg/migrations/sqlite3/main_20220504184155_fix_net_asset_column.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20220512170330_fix_profit_symbol_length.go b/pkg/migrations/sqlite3/main_20220512170330_fix_profit_symbol_length.go index 4c2510b49..511c84130 100644 --- a/pkg/migrations/sqlite3/main_20220512170330_fix_profit_symbol_length.go +++ b/pkg/migrations/sqlite3/main_20220512170330_fix_profit_symbol_length.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20220520140707_kline_unique_idx.go b/pkg/migrations/sqlite3/main_20220520140707_kline_unique_idx.go index 4431f8b1a..238c17246 100644 --- a/pkg/migrations/sqlite3/main_20220520140707_kline_unique_idx.go +++ b/pkg/migrations/sqlite3/main_20220520140707_kline_unique_idx.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20220531012226_margin_loans.go b/pkg/migrations/sqlite3/main_20220531012226_margin_loans.go index 87f72ccf7..d0c27e395 100644 --- a/pkg/migrations/sqlite3/main_20220531012226_margin_loans.go +++ b/pkg/migrations/sqlite3/main_20220531012226_margin_loans.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20220531013327_margin_repays.go b/pkg/migrations/sqlite3/main_20220531013327_margin_repays.go index 120727575..4f5ae38fa 100644 --- a/pkg/migrations/sqlite3/main_20220531013327_margin_repays.go +++ b/pkg/migrations/sqlite3/main_20220531013327_margin_repays.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20220531013541_margin_interests.go b/pkg/migrations/sqlite3/main_20220531013541_margin_interests.go index e10bc8043..22d899061 100644 --- a/pkg/migrations/sqlite3/main_20220531013541_margin_interests.go +++ b/pkg/migrations/sqlite3/main_20220531013541_margin_interests.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20220531015005_margin_liquidations.go b/pkg/migrations/sqlite3/main_20220531015005_margin_liquidations.go index 152932ae8..8761a5189 100644 --- a/pkg/migrations/sqlite3/main_20220531015005_margin_liquidations.go +++ b/pkg/migrations/sqlite3/main_20220531015005_margin_liquidations.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20230815173104_add_bybit_klines.go b/pkg/migrations/sqlite3/main_20230815173104_add_bybit_klines.go index cbe565154..b46c1b052 100644 --- a/pkg/migrations/sqlite3/main_20230815173104_add_bybit_klines.go +++ b/pkg/migrations/sqlite3/main_20230815173104_add_bybit_klines.go @@ -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) { diff --git a/pkg/migrations/sqlite3/main_20231123125402_fix_order_status_length.go b/pkg/migrations/sqlite3/main_20231123125402_fix_order_status_length.go index 9c5cb3711..c3c1ebf99 100644 --- a/pkg/migrations/sqlite3/main_20231123125402_fix_order_status_length.go +++ b/pkg/migrations/sqlite3/main_20231123125402_fix_order_status_length.go @@ -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) { diff --git a/pkg/migrations/sqlite3/migration_api.go b/pkg/migrations/sqlite3/migration_api.go index bf3dcfd66..cd67716b9 100644 --- a/pkg/migrations/sqlite3/migration_api.go +++ b/pkg/migrations/sqlite3/migration_api.go @@ -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)) } diff --git a/pkg/migrations/sqlite3/migration_api_test.go b/pkg/migrations/sqlite3/migration_api_test.go index 85fd38165..cb295ee42 100644 --- a/pkg/migrations/sqlite3/migration_api_test.go +++ b/pkg/migrations/sqlite3/migration_api_test.go @@ -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{}, }) }