1
bee generate migration create_users_table
을 통해 마이그레이션 파일을 이미 만들었습니다. 그런 다음 내가 폴더 데이터베이스/마이그레이션에 하나 개의 파일/20171205_154034_create_users_table.go 했다이 내 파일입니다마이그레이션 beego로 데이터베이스 생성
package main
import (
"github.com/astaxie/beego/migration"
)
// DO NOT MODIFY
type CreateUsersTable_20171205_154034 struct {
migration.Migration
}
// DO NOT MODIFY
func init() {
m := &CreateUsersTable_20171205_154034{}
m.Created = "20171205_154034"
migration.Register("CreateUsersTable_20171205_154034", m)
}
// Run the migrations
func (m *CreateUsersTable_20171205_154034) Up() {
m.CreateTable("users","InnoDB","utf8")
m.PriCol("id").SetAuto(true).SetNullable(false).SetDataType("INT(10)").SetUnsigned(true)
}
// Reverse the migrations
func (m *CreateUsersTable_20171205_154034) Down() {
m.SQL("DROP TABLE users")
}
마지막으로, 내가 bee migrate -conn="username:[email protected](127.0.0.1:3306)/mydb"
를 실행합니다. Migration successful!
오류가 없습니다. 하지만 데이터베이스에 사용자 테이블이 없었어요. 뭐가 문제 야? 읽어 주셔서 감사합니다. 누구든지 나를 도울 수 있기를 바랍니다