fix/schema-scope-qualifier#2647
Conversation
|
Thanks for the PR, @danyloshevchenkoingka. However, the "no-schema" behavior is detected from the database URL. Please, read about this in our website: https://atlasgo.io/concepts/url#scope |
When I generate migrations for a postgres database limited to a schema scope by specifying parameters the generated results include |
|
Please paste the full command. When working in schema scope, no |
$ atlas migrate diff init_db --dev-url "postgres://postgres:pass@127.0.0.1:5432/postgres?search_path=dev_schema&sslmode=disable" --to "postgres://user:pass@host:5432/itpgdb?search_path=iwar03&sslmode=disable" --dir-format golang-migrate --format '{{ sql . " " }}' |
|
I wasn't able to reproduce this: I recommend you to use the |
Execute altas with the |
|
If we look into the code, the condition to skip the schema qualifier in the function switch {
// Custom qualifier.
case b.Schema != nil:
// Empty means skip prefix.
if *b.Schema != "" {
b.Ident(*b.Schema)
b.rewriteLastByte('.')
}
// Default schema qualifier.
case s != nil && s.Name != "":
b.Ident(s.Name)
b.rewriteLastByte('.')
}If we specify the schema scope for the dev database, the I've updated the PR to fix this behaviour. |
I see what the issue is. The public schema has a default comment setting that is different than your schema. So, my docker:// example is irrelevant in this case. But using another local schema should do the work like I pasted above: #2647 (comment) |
The flag is default to empty string. The existing code is fine |
Yes, you're right, sorry.
Shouldn't we skip the change in this case? |
I don't think so. This is desired. I'm not sure I understand the issue, because the commands you gave above simply work for me. |
The PR adds a no-schema flag so that the generated migrations don't include a schema qualifier. This allows to generate cross-schema migrations
Resolves this issue: #1625