question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot alter schema: relation does not exist

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
elpranscommented, Sep 24, 2019

@cosmophile

I ❤️ edgedb!

Glad to hear that! 😃

Pickle errors didn’t go away

Those are expected, and just indicate that the parser cache is empty and needs to be rebuilt

If there’s any way I can help besides testing and using edgedb, please let me know.

Actually, testing, and writing extra tests for things that break, would be very helpful to the stabilization effort.

1reaction
elpranscommented, Sep 24, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot simply use PostgreSQL table name ("relation does ...
From what I've read, this error means that you're not referencing the table name correctly. One common reason is that the table is...
Read more >
Postgres : Relation does not exist error
But when I try to fire a select * query, it gave me this error: dump=> select * from Approvals; ERROR: relation "approvals"...
Read more >
Sequelize - How to fix relation does not exist error
In PostgreSQL, a relation does not exist error happens when you reference a table name that can't be found in the database you...
Read more >
SQL Error: relation "schema.table" does not exist"
Go to the gear option next to the connection name and hit "Refresh Tables and Schema" if the table has been renamed/deleted then...
Read more >
ERROR: relation "table_name" does not exist - Magento Forums
This means that a table created by alice, who is neither you nor a role than you are a member of (can be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found