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
Then the reverse migration will fail both because the target table name has a schema, and also because the schema isn't provided in the source table name.
'Impossible to automatically infer down migration for addConstraint without naming constraint'
);
What do you think?
Not sure if it is fully automatically possible to move a table to another schema, and even if, I would suggest to do it manually with another operation.
FFR: https://stackoverflow.com/a/17770152/6897682
Yeah, I don't think this needs to be robust to changing schemas, in fact I think it makes more sense to actually change the type signature to not include schema in the destination name since Postgres wouldn't do that either. So basically:
functionrenameTable(from: Name,to: string){// ...}// this works today:// up: renames public.foo to public.bar// down: renames public.bar to public.foorenameTable("foo","bar");// this does not work today:// up: renames a.foo to a.bar; this works today// down: renames a.bar to a.foo (read the schema from the `from` parameter)// this fails today, since we get ALTER TABLE "bar" RENAME TO a.foo// problems: "bar" lacks the schema, and a.foo shouldn't have the schema in it.renameTable({schema: "a",table: "foo"},"bar")
If we wanted to keep backwards compatible in the type signature and still allow any Name to be provided, then
if from.schema !== to.schema then throw an error
if it does equal, then throw away the schema for to and treat it the same way as the above example.
That said any code that does this would fail today, so I doubt that the breaking change would actually break any real migrations.
If you want to call SET SCHEMA, which ALTER TABLE does support, I have no issues with that being a separate command or just part of alterTable.
Describe the bug
If you do something like this:
It will fail because the schema is included in the new table name, which is not valid for this type of statement.
(If you try to change the schema at the same time, it will also fail for the same reason)
Then if you change it to
Then the reverse migration will fail both because the target table name has a schema, and also because the schema isn't provided in the source table name.
Steps to reproduce
No response
Logs
No response
System Info
Used Module System
cjs
The text was updated successfully, but these errors were encountered: