support logger auto call

This commit is contained in:
yanghao05
2023-01-29 15:27:50 +08:00
parent 34b3978c5a
commit 7151c52543
13 changed files with 284 additions and 589 deletions

View File

@@ -0,0 +1,45 @@
package migrations
import (
"atom/container"
"atom/contracts"
"log"
"go.uber.org/dig"
"gorm.io/gorm"
)
func init() {
if err := container.Container.Provide(New20140202InitMigration, dig.Group("migrations")); err != nil {
log.Fatal(err)
}
}
type Migration20140202Init struct {
id string
}
func New20140202InitMigration() contracts.Migration {
return &Migration20140202Init{id: "20140202_init"}
}
func (m *Migration20140202Init) ID() string {
return m.id
}
func (m *Migration20140202Init) Up(tx *gorm.DB) error {
table := m.table()
return tx.AutoMigrate(&table)
}
func (m *Migration20140202Init) Down(tx *gorm.DB) error {
return tx.Migrator().DropTable(m.table())
}
func (m *Migration20140202Init) table() interface{} {
type TableName struct {
FieldName string
}
return TableName{}
}