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:
Raphanus Lo 2022-05-12 18:21:07 +08:00
parent 44765e52d1
commit 075028f8fc
4 changed files with 90 additions and 0 deletions

View File

@ -0,0 +1,11 @@
-- +up
-- +begin
ALTER TABLE profits
CHANGE symbol symbol VARCHAR(20) NOT NULL;
-- +end
-- +down
-- +begin
SELECT 1;
-- +end

View File

@ -0,0 +1,11 @@
-- +up
-- +begin
ALTER TABLE profits
CHANGE symbol symbol VARCHAR(20) NOT NULL;
-- +end
-- +down
-- +begin
SELECT 1;
-- +end

View File

@ -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
}

View File

@ -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
}