separate atlas command
This commit is contained in:
@@ -7,7 +7,7 @@ type Patient struct {
|
||||
Active bool `json:"active"`
|
||||
// Name []HumanName `json:"name"`
|
||||
// Telecom []ContactPoint `json:"telecom"`
|
||||
Gender string `json:"gender"`
|
||||
Gender string `json:"gender" gorm:"size:10"`
|
||||
BirthDate string `json:"birthDate"`
|
||||
DeceasedBool bool `json:"deceasedBoolean"`
|
||||
// Address []Address `json:"address"`
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"ariga.io/atlas-provider-gorm/gormschema"
|
||||
"gorm.io/gorm"
|
||||
@@ -36,30 +35,7 @@ func getEntities(input string) []any {
|
||||
return nil
|
||||
}
|
||||
|
||||
func runAtlas(args ...string) error {
|
||||
cmd := exec.Command("atlas", args...)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
func logMsg(msg string) {
|
||||
fmt.Fprintln(os.Stderr, msg)
|
||||
}
|
||||
|
||||
func Migrate(input string) {
|
||||
loader(input)
|
||||
logMsg("Running atlas migrate diff...")
|
||||
if err := runAtlas("migrate", "diff", "--env", "gorm"); err != nil {
|
||||
logMsg(fmt.Sprintf("Failed to run diff: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
logMsg("Running atlas migrate apply...")
|
||||
if err := runAtlas("migrate", "apply", "--env", "gorm"); err != nil {
|
||||
logMsg(fmt.Sprintf("Failed to run apply: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
logMsg("Migration complete")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user