mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
migrations: add table column symbol length fix
This commit is contained in:
parent
3ce9d20a2b
commit
d83297b605
|
@ -7,12 +7,12 @@ CREATE TABLE `trades`
|
||||||
`id` BIGINT UNSIGNED,
|
`id` BIGINT UNSIGNED,
|
||||||
`order_id` BIGINT UNSIGNED NOT NULL,
|
`order_id` BIGINT UNSIGNED NOT NULL,
|
||||||
`exchange` VARCHAR(24) NOT NULL DEFAULT '',
|
`exchange` VARCHAR(24) NOT NULL DEFAULT '',
|
||||||
`symbol` VARCHAR(20) NOT NULL,
|
`symbol` VARCHAR(32) NOT NULL,
|
||||||
`price` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
`price` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
||||||
`quantity` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
`quantity` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
||||||
`quote_quantity` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
`quote_quantity` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
||||||
`fee` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
`fee` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
||||||
`fee_currency` VARCHAR(10) NOT NULL,
|
`fee_currency` VARCHAR(16) NOT NULL,
|
||||||
`is_buyer` BOOLEAN NOT NULL DEFAULT FALSE,
|
`is_buyer` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
`is_maker` BOOLEAN NOT NULL DEFAULT FALSE,
|
`is_maker` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
`side` VARCHAR(4) NOT NULL DEFAULT '',
|
`side` VARCHAR(4) NOT NULL DEFAULT '',
|
||||||
|
|
|
@ -9,7 +9,7 @@ CREATE TABLE `orders`
|
||||||
`order_id` BIGINT UNSIGNED NOT NULL,
|
`order_id` BIGINT UNSIGNED NOT NULL,
|
||||||
`client_order_id` VARCHAR(122) NOT NULL DEFAULT '',
|
`client_order_id` VARCHAR(122) NOT NULL DEFAULT '',
|
||||||
`order_type` VARCHAR(16) NOT NULL,
|
`order_type` VARCHAR(16) NOT NULL,
|
||||||
`symbol` VARCHAR(20) NOT NULL,
|
`symbol` VARCHAR(32) NOT NULL,
|
||||||
`status` VARCHAR(12) NOT NULL,
|
`status` VARCHAR(12) NOT NULL,
|
||||||
`time_in_force` VARCHAR(4) NOT NULL,
|
`time_in_force` VARCHAR(4) NOT NULL,
|
||||||
`price` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
`price` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
||||||
|
|
|
@ -6,7 +6,7 @@ CREATE TABLE `profits`
|
||||||
`strategy` VARCHAR(32) NOT NULL,
|
`strategy` VARCHAR(32) NOT NULL,
|
||||||
`strategy_instance_id` VARCHAR(64) NOT NULL,
|
`strategy_instance_id` VARCHAR(64) NOT NULL,
|
||||||
|
|
||||||
`symbol` VARCHAR(30) NOT NULL,
|
`symbol` VARCHAR(32) NOT NULL,
|
||||||
|
|
||||||
-- average_cost is the position average cost
|
-- average_cost is the position average cost
|
||||||
`average_cost` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
`average_cost` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
||||||
|
@ -25,7 +25,7 @@ CREATE TABLE `profits`
|
||||||
|
|
||||||
`quote_currency` VARCHAR(10) NOT NULL,
|
`quote_currency` VARCHAR(10) NOT NULL,
|
||||||
|
|
||||||
`base_currency` VARCHAR(15) NOT NULL,
|
`base_currency` VARCHAR(16) NOT NULL,
|
||||||
|
|
||||||
-- -------------------------------------------------------
|
-- -------------------------------------------------------
|
||||||
-- embedded trade data --
|
-- embedded trade data --
|
||||||
|
@ -61,7 +61,7 @@ CREATE TABLE `profits`
|
||||||
-- fee
|
-- fee
|
||||||
`fee_in_usd` DECIMAL(16, 8),
|
`fee_in_usd` DECIMAL(16, 8),
|
||||||
`fee` DECIMAL(16, 8) NOT NULL,
|
`fee` DECIMAL(16, 8) NOT NULL,
|
||||||
`fee_currency` VARCHAR(10) NOT NULL,
|
`fee_currency` VARCHAR(16) NOT NULL,
|
||||||
|
|
||||||
PRIMARY KEY (`gid`),
|
PRIMARY KEY (`gid`),
|
||||||
UNIQUE KEY `trade_id` (`trade_id`)
|
UNIQUE KEY `trade_id` (`trade_id`)
|
||||||
|
|
|
@ -8,7 +8,7 @@ CREATE TABLE `positions`
|
||||||
|
|
||||||
`symbol` VARCHAR(32) NOT NULL,
|
`symbol` VARCHAR(32) NOT NULL,
|
||||||
`quote_currency` VARCHAR(10) NOT NULL,
|
`quote_currency` VARCHAR(10) NOT NULL,
|
||||||
`base_currency` VARCHAR(15) NOT NULL,
|
`base_currency` VARCHAR(16) NOT NULL,
|
||||||
|
|
||||||
-- average_cost is the position average cost
|
-- average_cost is the position average cost
|
||||||
`average_cost` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
`average_cost` DECIMAL(16, 8) UNSIGNED NOT NULL,
|
||||||
|
@ -19,7 +19,7 @@ CREATE TABLE `positions`
|
||||||
-- trade related columns
|
-- trade related columns
|
||||||
`trade_id` BIGINT UNSIGNED NOT NULL, -- the trade id in the exchange
|
`trade_id` BIGINT UNSIGNED NOT NULL, -- the trade id in the exchange
|
||||||
`side` VARCHAR(4) NOT NULL, -- side of the trade
|
`side` VARCHAR(4) NOT NULL, -- side of the trade
|
||||||
`exchange` VARCHAR(12) NOT NULL, -- exchange of the trade
|
`exchange` VARCHAR(20) NOT NULL, -- exchange of the trade
|
||||||
`traded_at` DATETIME(3) NOT NULL, -- millisecond timestamp
|
`traded_at` DATETIME(3) NOT NULL, -- millisecond timestamp
|
||||||
|
|
||||||
PRIMARY KEY (`gid`),
|
PRIMARY KEY (`gid`),
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
-- +up
|
-- +up
|
||||||
-- +begin
|
-- +begin
|
||||||
ALTER TABLE profits
|
ALTER TABLE profits CHANGE symbol symbol VARCHAR(32) NOT NULL;
|
||||||
CHANGE symbol symbol VARCHAR(32) NOT NULL;
|
|
||||||
-- +end
|
-- +end
|
||||||
|
|
||||||
-- +down
|
-- +down
|
||||||
|
|
26
migrations/mysql/20240925160534_fix_symbol_length2.sql
Normal file
26
migrations/mysql/20240925160534_fix_symbol_length2.sql
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
-- +up
|
||||||
|
-- +begin
|
||||||
|
ALTER TABLE profits MODIFY COLUMN symbol VARCHAR(32) NOT NULL;
|
||||||
|
-- +end
|
||||||
|
|
||||||
|
-- +begin
|
||||||
|
ALTER TABLE profits MODIFY COLUMN base_currency VARCHAR(16) NOT NULL;
|
||||||
|
-- +end
|
||||||
|
|
||||||
|
-- +begin
|
||||||
|
ALTER TABLE profits MODIFY COLUMN fee_currency VARCHAR(16) NOT NULL;
|
||||||
|
-- +end
|
||||||
|
|
||||||
|
-- +begin
|
||||||
|
ALTER TABLE positions MODIFY COLUMN base_currency VARCHAR(16) NOT NULL;
|
||||||
|
-- +end
|
||||||
|
|
||||||
|
-- +begin
|
||||||
|
ALTER TABLE positions MODIFY COLUMN symbol VARCHAR(32) NOT NULL;
|
||||||
|
-- +end
|
||||||
|
|
||||||
|
-- +down
|
||||||
|
|
||||||
|
-- +begin
|
||||||
|
SELECT 1;
|
||||||
|
-- +end
|
10
migrations/sqlite3/20240925160534_fix_symbol_length2.sql
Normal file
10
migrations/sqlite3/20240925160534_fix_symbol_length2.sql
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
-- +up
|
||||||
|
-- +begin
|
||||||
|
SELECT 1;
|
||||||
|
-- +end
|
||||||
|
|
||||||
|
-- +down
|
||||||
|
|
||||||
|
-- +begin
|
||||||
|
SELECT 1;
|
||||||
|
-- +end
|
|
@ -12,7 +12,7 @@ func init() {
|
||||||
|
|
||||||
func up_main_trades(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
func up_main_trades(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||||
// This code is executed when the migration is applied.
|
// This code is executed when the migration is applied.
|
||||||
_, err = tx.ExecContext(ctx, "CREATE TABLE `trades`\n(\n `gid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,\n `id` BIGINT UNSIGNED,\n `order_id` BIGINT UNSIGNED NOT NULL,\n `exchange` VARCHAR(24) NOT NULL DEFAULT '',\n `symbol` VARCHAR(20) NOT NULL,\n `price` DECIMAL(16, 8) UNSIGNED NOT NULL,\n `quantity` DECIMAL(16, 8) UNSIGNED NOT NULL,\n `quote_quantity` DECIMAL(16, 8) UNSIGNED NOT NULL,\n `fee` DECIMAL(16, 8) UNSIGNED NOT NULL,\n `fee_currency` VARCHAR(10) NOT NULL,\n `is_buyer` BOOLEAN NOT NULL DEFAULT FALSE,\n `is_maker` BOOLEAN NOT NULL DEFAULT FALSE,\n `side` VARCHAR(4) NOT NULL DEFAULT '',\n `traded_at` DATETIME(3) NOT NULL,\n `is_margin` BOOLEAN NOT NULL DEFAULT FALSE,\n `is_isolated` BOOLEAN NOT NULL DEFAULT FALSE,\n `strategy` VARCHAR(32) NULL,\n `pnl` DECIMAL NULL,\n PRIMARY KEY (`gid`),\n UNIQUE KEY `id` (`exchange`, `symbol`, `side`, `id`)\n);")
|
_, err = tx.ExecContext(ctx, "CREATE TABLE `trades`\n(\n `gid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,\n `id` BIGINT UNSIGNED,\n `order_id` BIGINT UNSIGNED NOT NULL,\n `exchange` VARCHAR(24) NOT NULL DEFAULT '',\n `symbol` VARCHAR(32) NOT NULL,\n `price` DECIMAL(16, 8) UNSIGNED NOT NULL,\n `quantity` DECIMAL(16, 8) UNSIGNED NOT NULL,\n `quote_quantity` DECIMAL(16, 8) UNSIGNED NOT NULL,\n `fee` DECIMAL(16, 8) UNSIGNED NOT NULL,\n `fee_currency` VARCHAR(16) NOT NULL,\n `is_buyer` BOOLEAN NOT NULL DEFAULT FALSE,\n `is_maker` BOOLEAN NOT NULL DEFAULT FALSE,\n `side` VARCHAR(4) NOT NULL DEFAULT '',\n `traded_at` DATETIME(3) NOT NULL,\n `is_margin` BOOLEAN NOT NULL DEFAULT FALSE,\n `is_isolated` BOOLEAN NOT NULL DEFAULT FALSE,\n `strategy` VARCHAR(32) NULL,\n `pnl` DECIMAL NULL,\n PRIMARY KEY (`gid`),\n UNIQUE KEY `id` (`exchange`, `symbol`, `side`, `id`)\n);")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ func init() {
|
||||||
|
|
||||||
func up_main_orders(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
func up_main_orders(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||||
// This code is executed when the migration is applied.
|
// This code is executed when the migration is applied.
|
||||||
_, err = tx.ExecContext(ctx, "CREATE TABLE `orders`\n(\n `gid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,\n `exchange` VARCHAR(24) NOT NULL DEFAULT '',\n -- order_id is the order id returned from the exchange\n `order_id` BIGINT UNSIGNED NOT NULL,\n `client_order_id` VARCHAR(122) NOT NULL DEFAULT '',\n `order_type` VARCHAR(16) NOT NULL,\n `symbol` VARCHAR(20) NOT NULL,\n `status` VARCHAR(12) NOT NULL,\n `time_in_force` VARCHAR(4) NOT NULL,\n `price` DECIMAL(16, 8) UNSIGNED NOT NULL,\n `stop_price` DECIMAL(16, 8) UNSIGNED NOT NULL,\n `quantity` DECIMAL(16, 8) UNSIGNED NOT NULL,\n `executed_quantity` DECIMAL(16, 8) UNSIGNED NOT NULL DEFAULT 0.0,\n `side` VARCHAR(4) NOT NULL DEFAULT '',\n `is_working` BOOL NOT NULL DEFAULT FALSE,\n `created_at` DATETIME(3) NOT NULL,\n `updated_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),\n `is_margin` BOOLEAN NOT NULL DEFAULT FALSE,\n `is_isolated` BOOLEAN NOT NULL DEFAULT FALSE,\n PRIMARY KEY (`gid`)\n);")
|
_, err = tx.ExecContext(ctx, "CREATE TABLE `orders`\n(\n `gid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,\n `exchange` VARCHAR(24) NOT NULL DEFAULT '',\n -- order_id is the order id returned from the exchange\n `order_id` BIGINT UNSIGNED NOT NULL,\n `client_order_id` VARCHAR(122) NOT NULL DEFAULT '',\n `order_type` VARCHAR(16) NOT NULL,\n `symbol` VARCHAR(32) NOT NULL,\n `status` VARCHAR(12) NOT NULL,\n `time_in_force` VARCHAR(4) NOT NULL,\n `price` DECIMAL(16, 8) UNSIGNED NOT NULL,\n `stop_price` DECIMAL(16, 8) UNSIGNED NOT NULL,\n `quantity` DECIMAL(16, 8) UNSIGNED NOT NULL,\n `executed_quantity` DECIMAL(16, 8) UNSIGNED NOT NULL DEFAULT 0.0,\n `side` VARCHAR(4) NOT NULL DEFAULT '',\n `is_working` BOOL NOT NULL DEFAULT FALSE,\n `created_at` DATETIME(3) NOT NULL,\n `updated_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),\n `is_margin` BOOLEAN NOT NULL DEFAULT FALSE,\n `is_isolated` BOOLEAN NOT NULL DEFAULT FALSE,\n PRIMARY KEY (`gid`)\n);")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ func init() {
|
||||||
|
|
||||||
func up_main_addProfitTable(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
func up_main_addProfitTable(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||||
// This code is executed when the migration is applied.
|
// This code is executed when the migration is applied.
|
||||||
_, err = tx.ExecContext(ctx, "CREATE TABLE `profits`\n(\n `gid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,\n `strategy` VARCHAR(32) NOT NULL,\n `strategy_instance_id` VARCHAR(64) NOT NULL,\n `symbol` VARCHAR(8) NOT NULL,\n -- average_cost is the position average cost\n `average_cost` DECIMAL(16, 8) UNSIGNED NOT NULL,\n -- profit is the pnl (profit and loss)\n `profit` DECIMAL(16, 8) NOT NULL,\n -- net_profit is the pnl (profit and loss)\n `net_profit` DECIMAL(16, 8) NOT NULL,\n -- profit_margin is the pnl (profit and loss)\n `profit_margin` DECIMAL(16, 8) NOT NULL,\n -- net_profit_margin is the pnl (profit and loss)\n `net_profit_margin` DECIMAL(16, 8) NOT NULL,\n `quote_currency` VARCHAR(10) NOT NULL,\n `base_currency` VARCHAR(10) NOT NULL,\n -- -------------------------------------------------------\n -- embedded trade data --\n -- -------------------------------------------------------\n `exchange` VARCHAR(24) NOT NULL DEFAULT '',\n `is_futures` BOOLEAN NOT NULL DEFAULT FALSE,\n `is_margin` BOOLEAN NOT NULL DEFAULT FALSE,\n `is_isolated` BOOLEAN NOT NULL DEFAULT FALSE,\n `trade_id` BIGINT UNSIGNED NOT NULL,\n -- side is the side of the trade that makes profit\n `side` VARCHAR(4) NOT NULL DEFAULT '',\n `is_buyer` BOOLEAN NOT NULL DEFAULT FALSE,\n `is_maker` BOOLEAN NOT NULL DEFAULT FALSE,\n -- price is the price of the trade that makes profit\n `price` DECIMAL(16, 8) UNSIGNED NOT NULL,\n -- quantity is the quantity of the trade that makes profit\n `quantity` DECIMAL(16, 8) UNSIGNED NOT NULL,\n -- quote_quantity is the quote quantity of the trade that makes profit\n `quote_quantity` DECIMAL(16, 8) UNSIGNED NOT NULL,\n `traded_at` DATETIME(3) NOT NULL,\n -- fee\n `fee_in_usd` DECIMAL(16, 8),\n `fee` DECIMAL(16, 8) NOT NULL,\n `fee_currency` VARCHAR(10) NOT NULL,\n PRIMARY KEY (`gid`),\n UNIQUE KEY `trade_id` (`trade_id`)\n);")
|
_, err = tx.ExecContext(ctx, "CREATE TABLE `profits`\n(\n `gid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,\n `strategy` VARCHAR(32) NOT NULL,\n `strategy_instance_id` VARCHAR(64) NOT NULL,\n `symbol` VARCHAR(32) NOT NULL,\n -- average_cost is the position average cost\n `average_cost` DECIMAL(16, 8) UNSIGNED NOT NULL,\n -- profit is the pnl (profit and loss)\n `profit` DECIMAL(16, 8) NOT NULL,\n -- net_profit is the pnl (profit and loss)\n `net_profit` DECIMAL(16, 8) NOT NULL,\n -- profit_margin is the pnl (profit and loss)\n `profit_margin` DECIMAL(16, 8) NOT NULL,\n -- net_profit_margin is the pnl (profit and loss)\n `net_profit_margin` DECIMAL(16, 8) NOT NULL,\n `quote_currency` VARCHAR(10) NOT NULL,\n `base_currency` VARCHAR(16) NOT NULL,\n -- -------------------------------------------------------\n -- embedded trade data --\n -- -------------------------------------------------------\n `exchange` VARCHAR(24) NOT NULL DEFAULT '',\n `is_futures` BOOLEAN NOT NULL DEFAULT FALSE,\n `is_margin` BOOLEAN NOT NULL DEFAULT FALSE,\n `is_isolated` BOOLEAN NOT NULL DEFAULT FALSE,\n `trade_id` BIGINT UNSIGNED NOT NULL,\n -- side is the side of the trade that makes profit\n `side` VARCHAR(4) NOT NULL DEFAULT '',\n `is_buyer` BOOLEAN NOT NULL DEFAULT FALSE,\n `is_maker` BOOLEAN NOT NULL DEFAULT FALSE,\n -- price is the price of the trade that makes profit\n `price` DECIMAL(16, 8) UNSIGNED NOT NULL,\n -- quantity is the quantity of the trade that makes profit\n `quantity` DECIMAL(16, 8) UNSIGNED NOT NULL,\n -- quote_quantity is the quote quantity of the trade that makes profit\n `quote_quantity` DECIMAL(16, 8) UNSIGNED NOT NULL,\n `traded_at` DATETIME(3) NOT NULL,\n -- fee\n `fee_in_usd` DECIMAL(16, 8),\n `fee` DECIMAL(16, 8) NOT NULL,\n `fee_currency` VARCHAR(16) NOT NULL,\n PRIMARY KEY (`gid`),\n UNIQUE KEY `trade_id` (`trade_id`)\n);")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ func init() {
|
||||||
|
|
||||||
func up_main_addPositions(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
func up_main_addPositions(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||||
// This code is executed when the migration is applied.
|
// This code is executed when the migration is applied.
|
||||||
_, err = tx.ExecContext(ctx, "CREATE TABLE `positions`\n(\n `gid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,\n `strategy` VARCHAR(32) NOT NULL,\n `strategy_instance_id` VARCHAR(64) NOT NULL,\n `symbol` VARCHAR(20) NOT NULL,\n `quote_currency` VARCHAR(10) NOT NULL,\n `base_currency` VARCHAR(10) NOT NULL,\n -- average_cost is the position average cost\n `average_cost` DECIMAL(16, 8) UNSIGNED NOT NULL,\n `base` DECIMAL(16, 8) NOT NULL,\n `quote` DECIMAL(16, 8) NOT NULL,\n `profit` DECIMAL(16, 8) NULL,\n -- trade related columns\n `trade_id` BIGINT UNSIGNED NOT NULL, -- the trade id in the exchange\n `side` VARCHAR(4) NOT NULL, -- side of the trade\n `exchange` VARCHAR(12) NOT NULL, -- exchange of the trade\n `traded_at` DATETIME(3) NOT NULL, -- millisecond timestamp\n PRIMARY KEY (`gid`),\n UNIQUE KEY `trade_id` (`trade_id`, `side`, `exchange`)\n);")
|
_, err = tx.ExecContext(ctx, "CREATE TABLE `positions`\n(\n `gid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,\n `strategy` VARCHAR(32) NOT NULL,\n `strategy_instance_id` VARCHAR(64) NOT NULL,\n `symbol` VARCHAR(32) NOT NULL,\n `quote_currency` VARCHAR(10) NOT NULL,\n `base_currency` VARCHAR(16) NOT NULL,\n -- average_cost is the position average cost\n `average_cost` DECIMAL(16, 8) UNSIGNED NOT NULL,\n `base` DECIMAL(16, 8) NOT NULL,\n `quote` DECIMAL(16, 8) NOT NULL,\n `profit` DECIMAL(16, 8) NULL,\n -- trade related columns\n `trade_id` BIGINT UNSIGNED NOT NULL, -- the trade id in the exchange\n `side` VARCHAR(4) NOT NULL, -- side of the trade\n `exchange` VARCHAR(20) NOT NULL, -- exchange of the trade\n `traded_at` DATETIME(3) NOT NULL, -- millisecond timestamp\n PRIMARY KEY (`gid`),\n UNIQUE KEY `trade_id` (`trade_id`, `side`, `exchange`)\n);")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ func init() {
|
||||||
|
|
||||||
func up_main_fixProfitSymbolLength(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
func up_main_fixProfitSymbolLength(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||||
// This code is executed when the migration is applied.
|
// This code is executed when the migration is applied.
|
||||||
_, err = tx.ExecContext(ctx, "ALTER TABLE profits\n CHANGE symbol symbol VARCHAR(20) NOT NULL;")
|
_, err = tx.ExecContext(ctx, "ALTER TABLE profits CHANGE symbol symbol VARCHAR(32) NOT NULL;")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
package mysql
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/c9s/rockhopper/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
AddMigration("main", up_main_fixSymbolLength2, down_main_fixSymbolLength2)
|
||||||
|
}
|
||||||
|
|
||||||
|
func up_main_fixSymbolLength2(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||||
|
// This code is executed when the migration is applied.
|
||||||
|
_, err = tx.ExecContext(ctx, "ALTER TABLE profits MODIFY COLUMN symbol VARCHAR(32) NOT NULL;")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = tx.ExecContext(ctx, "ALTER TABLE profits MODIFY COLUMN base_currency VARCHAR(16) NOT NULL;")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = tx.ExecContext(ctx, "ALTER TABLE profits MODIFY COLUMN fee_currency VARCHAR(16) NOT NULL;")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = tx.ExecContext(ctx, "ALTER TABLE positions MODIFY COLUMN base_currency VARCHAR(16) NOT NULL;")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = tx.ExecContext(ctx, "ALTER TABLE positions MODIFY COLUMN symbol VARCHAR(32) NOT NULL;")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func down_main_fixSymbolLength2(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
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package sqlite3
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/c9s/rockhopper/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
AddMigration("main", up_main_fixSymbolLength2, down_main_fixSymbolLength2)
|
||||||
|
}
|
||||||
|
|
||||||
|
func up_main_fixSymbolLength2(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_fixSymbolLength2(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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user