mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
Merge pull request #346 from tony1223/bug/343-fee_currency_length
This commit is contained in:
commit
0c7bbba675
|
@ -562,6 +562,14 @@ Then run the following command to compile the migration files into go files:
|
|||
make migrations
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```shell
|
||||
rockhopper compile --config rockhopper_mysql.yaml --output pkg/migrations/mysql
|
||||
rockhopper compile --config rockhopper_sqlite.yaml --output pkg/migrations/sqlite3
|
||||
git add -v pkg/migrations && git commit -m "compile and update migration package" pkg/migrations || true
|
||||
```
|
||||
|
||||
|
||||
If you want to override the DSN and the Driver defined in the YAML config file, you can add some env vars in your dotenv file like this:
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
-- +up
|
||||
-- +begin
|
||||
ALTER TABLE trades CHANGE fee_currency fee_currency varchar(10) NOT NULL;
|
||||
-- +end
|
||||
|
||||
-- +down
|
||||
-- +begin
|
||||
ALTER TABLE trades CHANGE fee_currency fee_currency varchar(4) NOT NULL;
|
||||
-- +end
|
|
@ -0,0 +1,8 @@
|
|||
-- +up
|
||||
-- +begin
|
||||
-- +end
|
||||
|
||||
-- +down
|
||||
|
||||
-- +begin
|
||||
-- +end
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue
Block a user