compile and update migration package

This commit is contained in:
TonyQ 2021-12-11 10:40:11 +08:00
parent 9f14d00f3c
commit c38564dcc7
2 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,34 @@
package mysql
import (
"context"
"github.com/c9s/rockhopper"
)
func init() {
AddMigration(upUpdateFeeCurrencyLength, downUpdateFeeCurrencyLength)
}
func upUpdateFeeCurrencyLength(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
// This code is executed when the migration is applied.
_, err = tx.ExecContext(ctx, "ALTER TABLE trades CHANGE fee_currency fee_currency varchar(10) NOT NULL;")
if err != nil {
return err
}
return err
}
func downUpdateFeeCurrencyLength(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
// This code is executed when the migration is rolled back.
_, err = tx.ExecContext(ctx, "ALTER TABLE trades CHANGE fee_currency fee_currency varchar(4) NOT NULL;")
if err != nil {
return err
}
return err
}

View File

@ -0,0 +1,34 @@
package sqlite3
import (
"context"
"github.com/c9s/rockhopper"
)
func init() {
AddMigration(upUpdateFeeCurrencyLength, downUpdateFeeCurrencyLength)
}
func upUpdateFeeCurrencyLength(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
// This code is executed when the migration is applied.
_, err = tx.ExecContext(ctx, "")
if err != nil {
return err
}
return err
}
func downUpdateFeeCurrencyLength(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
// This code is executed when the migration is rolled back.
_, err = tx.ExecContext(ctx, "")
if err != nil {
return err
}
return err
}