-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I set up atlas to only migrate some models? #24
Comments
Um guessing at this point you have found a solution or given up but in case someone else ends up here: It seems that atlas doesn't support the type UserWithAddress struct {
User
Address string `gorm:"column:address"`
} |
Hey, If you need something more involved, I suggest using Go Program Mode which give you ultimate control on the models the provider uses as the desired schema. |
Same issue, my workaround is to declare abstract models in a different package, and concrete models in the package that I provide to atlas, e.g.: # ./db/abstract/models.go:
type BaseModel struct {
ID int64 `gorm:"primarykey;autoIncrement"`
}
# ./db/concrete/models.go:
import base "./db/abstract"
type User struct {
base.BaseModel
Username string
...
} and the hcl file: data "external_schema" "gorm" {
program = [
"go",
"run",
"ariga.io/atlas-provider-gorm",
"load",
"--path", "./db/concrete",
"--dialect", "mysql",
]
} |
Hi,
is there a way to set-up atlas to specify what models I want to exclude?
In our project we define some helper models that we do not migrate to the DB, we only work with them in the program itself.
Small example that doesn't really make sense:
atlas.hcl
What gets generated with
atlas migrate diff
The schema that GORM creates:
Is there a way for me to achieve this?
The text was updated successfully, but these errors were encountered: