mirror of https://github.com/status-im/migrate.git
rename Migration.LongString to LogString
This commit is contained in:
parent
c1b23fee45
commit
1b079a3cda
16
migrate.go
16
migrate.go
|
@ -295,9 +295,9 @@ func (m *Migrate) Run(migration ...*Migration) error {
|
||||||
defer close(ret)
|
defer close(ret)
|
||||||
for _, migr := range migration {
|
for _, migr := range migration {
|
||||||
if m.PrefetchMigrations > 0 && migr.Body != nil {
|
if m.PrefetchMigrations > 0 && migr.Body != nil {
|
||||||
m.logVerbosePrintf("Start buffering %v\n", migr.StringLong())
|
m.logVerbosePrintf("Start buffering %v\n", migr.LogString())
|
||||||
} else {
|
} else {
|
||||||
m.logVerbosePrintf("Scheduled %v\n", migr.StringLong())
|
m.logVerbosePrintf("Scheduled %v\n", migr.LogString())
|
||||||
}
|
}
|
||||||
|
|
||||||
ret <- migr
|
ret <- migr
|
||||||
|
@ -629,13 +629,13 @@ func (m *Migrate) runMigrations(ret <-chan interface{}) error {
|
||||||
migr := r.(*Migration)
|
migr := r.(*Migration)
|
||||||
|
|
||||||
if migr.Body == nil {
|
if migr.Body == nil {
|
||||||
m.logVerbosePrintf("Execute %v\n", migr.StringLong())
|
m.logVerbosePrintf("Execute %v\n", migr.LogString())
|
||||||
if err := m.databaseDrv.Run(migr.TargetVersion, nil); err != nil {
|
if err := m.databaseDrv.Run(migr.TargetVersion, nil); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
m.logVerbosePrintf("Read and execute %v\n", migr.StringLong())
|
m.logVerbosePrintf("Read and execute %v\n", migr.LogString())
|
||||||
if err := m.databaseDrv.Run(migr.TargetVersion, migr.BufferedBody); err != nil {
|
if err := m.databaseDrv.Run(migr.TargetVersion, migr.BufferedBody); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -648,9 +648,9 @@ func (m *Migrate) runMigrations(ret <-chan interface{}) error {
|
||||||
// log either verbose or normal
|
// log either verbose or normal
|
||||||
if m.Log != nil {
|
if m.Log != nil {
|
||||||
if m.Log.Verbose() {
|
if m.Log.Verbose() {
|
||||||
m.logPrintf("Finished %v (read %v, ran %v)\n", migr.StringLong(), readTime, runTime)
|
m.logPrintf("Finished %v (read %v, ran %v)\n", migr.LogString(), readTime, runTime)
|
||||||
} else {
|
} else {
|
||||||
m.logPrintf("%v (%v)\n", migr.StringLong(), readTime+runTime)
|
m.logPrintf("%v (%v)\n", migr.LogString(), readTime+runTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -754,9 +754,9 @@ func (m *Migrate) newMigration(version uint, targetVersion int) (*Migration, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.PrefetchMigrations > 0 && migr.Body != nil {
|
if m.PrefetchMigrations > 0 && migr.Body != nil {
|
||||||
m.logVerbosePrintf("Start buffering %v\n", migr.StringLong())
|
m.logVerbosePrintf("Start buffering %v\n", migr.LogString())
|
||||||
} else {
|
} else {
|
||||||
m.logVerbosePrintf("Scheduled %v\n", migr.StringLong())
|
m.logVerbosePrintf("Scheduled %v\n", migr.LogString())
|
||||||
}
|
}
|
||||||
|
|
||||||
return migr, nil
|
return migr, nil
|
||||||
|
|
|
@ -108,8 +108,7 @@ func (m *Migration) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// StringLong returns a string describing this migration to humans.
|
// StringLong returns a string describing this migration to humans.
|
||||||
// TODO: rename to LogString()
|
func (m *Migration) LogString() string {
|
||||||
func (m *Migration) StringLong() string {
|
|
||||||
directionStr := "u"
|
directionStr := "u"
|
||||||
if m.TargetVersion < int(m.Version) {
|
if m.TargetVersion < int(m.Version) {
|
||||||
directionStr = "d"
|
directionStr = "d"
|
||||||
|
|
|
@ -19,7 +19,7 @@ func ExampleNewMigration() {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Print(migr.StringLong())
|
fmt.Print(migr.LogString())
|
||||||
// Output:
|
// Output:
|
||||||
// 1486686016/u create_users_table
|
// 1486686016/u create_users_table
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ func ExampleNewMigration_nilMigration() {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Print(migr.StringLong())
|
fmt.Print(migr.LogString())
|
||||||
// Output:
|
// Output:
|
||||||
// 1486686016/u <empty>
|
// 1486686016/u <empty>
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ func ExampleNewMigration_nilVersion() {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Print(migr.StringLong())
|
fmt.Print(migr.LogString())
|
||||||
// Output:
|
// Output:
|
||||||
// 1486686016/d drop_users_table
|
// 1486686016/d drop_users_table
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue