efcaa3d9 by astaxie

update the migration database time format

1 parent 5ecfe0c3
...@@ -23,7 +23,6 @@ package migration ...@@ -23,7 +23,6 @@ package migration
23 import ( 23 import (
24 "errors" 24 "errors"
25 "sort" 25 "sort"
26 "strconv"
27 "strings" 26 "strings"
28 "time" 27 "time"
29 28
...@@ -32,7 +31,10 @@ import ( ...@@ -32,7 +31,10 @@ import (
32 ) 31 )
33 32
34 // const the data format for the bee generate migration datatype 33 // const the data format for the bee generate migration datatype
35 const M_DATE_FORMAT = "20060102_150405" 34 const (
35 M_DATE_FORMAT = "20060102_150405"
36 M_DB_DATE_FORMAT = "2006-01-02 15:04:05"
37 )
36 38
37 // Migrationer is an interface for all Migration struct 39 // Migrationer is an interface for all Migration struct
38 type Migrationer interface { 40 type Migrationer interface {
...@@ -99,7 +101,11 @@ func (m *Migration) addOrUpdateRecord(name, status string) error { ...@@ -99,7 +101,11 @@ func (m *Migration) addOrUpdateRecord(name, status string) error {
99 if err != nil { 101 if err != nil {
100 return err 102 return err
101 } 103 }
102 _, err = p.Exec(name, strconv.FormatInt(m.GetCreated(), 10), strings.Join(m.sqls, "; "), status) 104 t, err := time.Parse(M_DB_DATE_FORMAT, m.Created)
105 if err != nil {
106 return err
107 }
108 _, err = p.Exec(name, t.Format(M_DB_DATE_FORMAT), strings.Join(m.sqls, "; "), status)
103 return err 109 return err
104 } 110 }
105 } 111 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!