mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
Fix symbol length in profits
This change fixes "Error 1406: Data too long for column 'symbol' at row 1" for pair symbol longer than 8 chars. Fixes #608
This commit is contained in:
parent
44765e52d1
commit
075028f8fc
11
migrations/mysql/20220512170322_fix_profit_symbol_length.sql
Normal file
11
migrations/mysql/20220512170322_fix_profit_symbol_length.sql
Normal file
|
@ -0,0 +1,11 @@
|
|||
-- +up
|
||||
-- +begin
|
||||
ALTER TABLE profits
|
||||
CHANGE symbol symbol VARCHAR(20) NOT NULL;
|
||||
-- +end
|
||||
|
||||
-- +down
|
||||
|
||||
-- +begin
|
||||
SELECT 1;
|
||||
-- +end
|
|
@ -0,0 +1,11 @@
|
|||
-- +up
|
||||
-- +begin
|
||||
ALTER TABLE profits
|
||||
CHANGE symbol symbol VARCHAR(20) NOT NULL;
|
||||
-- +end
|
||||
|
||||
-- +down
|
||||
|
||||
-- +begin
|
||||
SELECT 1;
|
||||
-- +end
|
|
@ -0,0 +1,34 @@
|
|||
package mysql
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/c9s/rockhopper"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddMigration(upFixProfitSymbolLength, downFixProfitSymbolLength)
|
||||
|
||||
}
|
||||
|
||||
func upFixProfitSymbolLength(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
// This code is executed when the migration is applied.
|
||||
|
||||
_, err = tx.ExecContext(ctx, "ALTER TABLE profits\n CHANGE symbol symbol VARCHAR(20) NOT NULL;")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func downFixProfitSymbolLength(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,34 @@
|
|||
package sqlite3
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/c9s/rockhopper"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddMigration(upFixProfitSymbolLength, downFixProfitSymbolLength)
|
||||
|
||||
}
|
||||
|
||||
func upFixProfitSymbolLength(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
// This code is executed when the migration is applied.
|
||||
|
||||
_, err = tx.ExecContext(ctx, "ALTER TABLE profits\n CHANGE symbol symbol VARCHAR(20) NOT NULL;")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func downFixProfitSymbolLength(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