Going through the same issue, I am using MySql. Here is how I did it -
Created a migration file with bee generate:
$ bee generate migration user
2016/06/26 13:36:31 [INFO] Using 'user' as migration name
2016/06/26 13:36:32 [INFO] Migration file generated: /path/to/project/database/migrations/20160626_140247_user.go
2016/06/26 13:36:32 [SUCC] generate successfully created!
, :
package main
import (
"github.com/astaxie/beego/migration"
)
// DO NOT MODIFY
type User_20160626_140247 struct {
migration.Migration
}
// DO NOT MODIFY
func init() {
m := &User_20160626_140247{}
m.Created = "20160626_140247"
migration.Register("User_20160626_140247", m)
}
// Run the migrations
func (m *User_20160626_140247) Up() {
// use m.SQL("CREATE TABLE ...") to make schema update
}
// Reverse the migrations
func (m *User_20160626_140247) Down() {
// use m.SQL("DROP TABLE ...") to reverse schema update
}
Up Down. , m.SQL SQL-. alter .
, bee migrate, . -
$bee migrate -conn="username:password@tcp(127.0.0.1:3306)/mydb"
, .