Cannot alter schema: relation does not exist
See original GitHub issueI started with a clean test database and committed the example schema on the front page of edgedb.com (the one with types like Issue, Comment, LogEntry etc).
Then I tried to overwrite the whole schema with an SDL that only contained a type called User, and got the following error:
SchemaError: cannot drop object type 'default::Status' because other objects in the schema depend on it
DETAILS: link 'status' of object type 'default::Issue' depends on default::Status
I had been under the mistaken impression that SDL could overwrite relational schemas and simply migrate the schema to a new state, but even without any data I couldn’t remove multiple relations at once.
OK. So I tried to drop related types one by one.
DROP type Comment;
ALTER type Issue { drop link status; drop link priority; drop link watchers; };
DROP type Status;
DROP type Priority;
ALTER type Owned drop link owner;
DROP type User;
But every time I try to run the following:
ALTER TYPE Issue { drop link time_spent_log };
I get the following error (which I also get if I just straight up try to drop type Issue without dropping its links first):
InternalServerError: relation "edgedb_0c374af0-b9e5-11e9-9e0e-8386bcc80f19.fd59ef02-ded1-11e9-9af1-2767b4bb0170" does not exist
Can’t understand this error. I saw that time_spent_log
has an exclusive
constraint (and is mullti) so I tried to remove the constraint first (even though it surely shouldn’t be necessary?):
ALTER TYPE Issue ALTER LINK time_spent_log DROP CONSTRAINT exclusive;
and got this new error:
InvalidReferenceError: reference to a non-existent schema item: default::std|exclusive@@default|default|time_spent_log@@default|Issue
So then I tried to alter the link like so (because why not):
ALTER TYPE Issue ALTER LINK time_spent_log SET SINGLE;
This worked, but now when I tried to drop the link time_spent_log
from type Issue
, I got a new error again:
InternalServerError: trigger "6f581a40-ded7-11e9-bfc4-81bfc26ffadb;schemaconstr_instrigger" for table "6f47b3c8-ded7-11e9-8f18-c9bcacf4759e" does not exist
Note that when I introspect the Issue type, the exclusive constraint does show up and the cardinality has become ONE.
So any help on how I can alter this schema to something potentially completely unrelated would be much appreciated!
Also would love more clarity on how to validate SDL migrations. Is it intended behaviour that links must be dropped first (using DDL) before a linked type can be deleted? Thanks again.
PS: Since the exclusive constraint is the only thing that’s different about the error-giving link, I’m guessing it is in fact required to remove the constraint first? In which case it could be a syntax error on my part. FWIW I used the example at the bottom of the DDL Constraints doc page as my reference.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
@cosmophile
Glad to hear that! 😃
Those are expected, and just indicate that the parser cache is empty and needs to be rebuilt
Actually, testing, and writing extra tests for things that break, would be very helpful to the stabilization effort.
Hi @cosmophile. We have made a bunch of fixes for migrations in master, so most of those issues have been fixed. We are working on setting the nightly builds up to make it easier to test the master branch. Meanwhile you can try setting up a dev version, the instructions are here: https://edgedb.com/docs/internals/dev