37 lines
669 B
Go
37 lines
669 B
Go
package migration
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
eu "simrs-vx/internal/domain/main-entities/user"
|
|
|
|
"ariga.io/atlas-provider-gorm/gormschema"
|
|
)
|
|
|
|
type Config struct {
|
|
DbCfg DbConf `yaml:"dbCfg"`
|
|
}
|
|
|
|
type DbConf struct {
|
|
DSN string `yaml:"dsn"`
|
|
MaxOpenConns int `yaml:"maxOpenConns"`
|
|
MaxIdleConns int `yaml:"maxIdleConns"`
|
|
MaxIdleTime int `yaml:"maxIdleTime"`
|
|
}
|
|
|
|
func Migrate() {
|
|
stmts, err := gormschema.New("postgres").Load(getEntities()...)
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "failed to load gorm schema: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
_, _ = io.WriteString(os.Stdout, stmts)
|
|
}
|
|
|
|
func getEntities() []any {
|
|
return []any{
|
|
&eu.User{},
|
|
}
|
|
}
|