You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to migrate my Ent./Atlas multi-schema configuration to a composite schema, but am struggling with DB schema annotations. In my first attempt I just migrated atlas.hcl to use a composite without making any changes to the Ent. schemas themselves.
[...]
data "composite_schema" "api_services" {
# one schema is enough to illustrate the issue.
schema "core" {
url = "ent://ent/schema"
}
}
env "ent" {
dev = "docker://postgres/15"
migration {
dir = "file://migrations"
}
src = data.composite_schema.api_services.url
}
However, trying to generate the migration spits out the following error:
atlas migrate diff test --env=ent
Creating new migration test ...
Error: data.composite_schema.api_services: unnecessary schema "core" specified in --dev-url for multi-schema mode. See: https://atlasgo.io/url
Hmm, not very obvious what this means and looking at the referenced documentation didn't tell me much either. After some experimentation I figured out that removing the DB schema annotation from all Ent. schema lets me create the migration without errors, i.e.:
ent/schema/test.go
type Test struct {
ent.Schema
}
func (Test) Annotations() []schema.Annotation {
return []schema.Annotation{
// entsql.Schema("core"),
[...]
}
}
The migration can be applied to the DB successfully and everything appears in the correct place, i.e. the right schema (core). When I ran the test suite however, I somewhat predictably go the following error:
ERROR: relation "test" does not exist (SQLSTATE 42P01)
Not overly surprising since AFAIK Ent.'s code generation doesn't take Atlas' configuration into account at all. Nevertheless, I can't figure out how to set this all up so both migrations and entity framework work. My hunch is that the DB schema annotation is required in the Ent. schema - but how to make Atlas accept this?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I'm trying to migrate my Ent./Atlas multi-schema configuration to a composite schema, but am struggling with DB schema annotations. In my first attempt I just migrated
atlas.hcl
to use a composite without making any changes to the Ent. schemas themselves.ent/schema/test.go
atlas.hcl
However, trying to generate the migration spits out the following error:
Hmm, not very obvious what this means and looking at the referenced documentation didn't tell me much either. After some experimentation I figured out that removing the DB schema annotation from all Ent. schema lets me create the migration without errors, i.e.:
ent/schema/test.go
The migration can be applied to the DB successfully and everything appears in the correct place, i.e. the right schema (
core
). When I ran the test suite however, I somewhat predictably go the following error:Not overly surprising since AFAIK Ent.'s code generation doesn't take Atlas' configuration into account at all. Nevertheless, I can't figure out how to set this all up so both migrations and entity framework work. My hunch is that the DB schema annotation is required in the Ent. schema - but how to make Atlas accept this?
Any pointers highly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions