From c38564dcc73d8043ef0224eb818b753aa3f71ac4 Mon Sep 17 00:00:00 2001 From: TonyQ Date: Sat, 11 Dec 2021 10:40:11 +0800 Subject: [PATCH] compile and update migration package --- ...211211103657_update_fee_currency_length.go | 34 +++++++++++++++++++ ...211211103657_update_fee_currency_length.go | 34 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 pkg/migrations/mysql/20211211103657_update_fee_currency_length.go create mode 100644 pkg/migrations/sqlite3/20211211103657_update_fee_currency_length.go diff --git a/pkg/migrations/mysql/20211211103657_update_fee_currency_length.go b/pkg/migrations/mysql/20211211103657_update_fee_currency_length.go new file mode 100644 index 000000000..887307586 --- /dev/null +++ b/pkg/migrations/mysql/20211211103657_update_fee_currency_length.go @@ -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 +} diff --git a/pkg/migrations/sqlite3/20211211103657_update_fee_currency_length.go b/pkg/migrations/sqlite3/20211211103657_update_fee_currency_length.go new file mode 100644 index 000000000..ec7373937 --- /dev/null +++ b/pkg/migrations/sqlite3/20211211103657_update_fee_currency_length.go @@ -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 +}