github.com/sharovik/devbot@v1.0.1-0.20240308094637-4a0387c40516/scripts/update/migrations/2-example-migration.go (about) 1 package migrations 2 3 import ( 4 "github.com/sharovik/devbot/internal/container" 5 "github.com/sharovik/devbot/internal/dto/databasedto" 6 "github.com/sharovik/orm/clients" 7 "github.com/sharovik/orm/query" 8 ) 9 10 type ExampleMigration struct { 11 Client clients.BaseClientInterface 12 } 13 14 func (m ExampleMigration) SetClient(client clients.BaseClientInterface) { 15 m.Client = client 16 } 17 18 func (m ExampleMigration) GetName() string { 19 return "example-migration" 20 } 21 22 func (m ExampleMigration) Execute() error { 23 client := container.C.Dictionary.GetDBClient() 24 25 q := new(clients.Query). 26 Select(databasedto.MigrationModel.GetColumns()). 27 From(databasedto.MigrationModel). 28 Where(query.Where{ 29 First: "1", 30 Operator: "=", 31 Second: "1", 32 }) 33 _, err := client.Execute(q) 34 if err != nil { 35 return err 36 } 37 38 return nil 39 }