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.

InternalServerError: cannot alter type

See original GitHub issue
  • EdgeDB Version: EdgeDB 1.0-alpha.2+g16f75ece5.d20200122
  • OS Version: Windos 10 Educational, Version: 1909, Build: 18363.778

Steps to Reproduce:

START TRANSACTION;
CREATE MIGRATION m2 TO {
    module default {
        type User {
            required property scopes -> array<scope>;
        }
        scalar type scope extending str {
            constraint one_of (
                '1', '2'
            );
        }
    }
};
COMMIT MIGRATION m2;
COMMIT;

Error log:

InternalServerError: cannot alter type ""edgedb_e1d3ab02-7c59-11ea-9cc7-f7e49d2fb386"."87c9d94a-87f0-11ea-b4ba-db2bb9dbfd2b_domain"" because column "6716f2a1-87ef-11ea-bb56-fd1198a88276.scopes" uses it

May be related to this issue #1369.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
elpranscommented, Apr 26, 2020

Right, so then the only way around is to use DDL commands directly (and in correct order):

create scalar type scope extending str {
    create constraint one_of ('1', '2');
};

create type User {
    create required property scopes -> array<scope>;
};

0reactions
msullivancommented, Mar 25, 2021

This particular manifestation of the issue should be easy to fix: because of the vagaries of the priority system, pgsql/delta.py just happens to be creating the constraint late, in a way that puts it after the table and column are created.

The trickier thing is when we need to do a bona-fide alter that adds a constraint. I think the approach is going to have to be:

  1. Alter all of the columns that use the type as part of a composite to use an equivalent type. This could require creating temporary tuple types.
  2. Add the constraint to the domain
  3. Alter all the columns back. Delete any temporary types.

That is nasty, but definitely doable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ERROR: cannot alter type of a column used by a view or rule ...
The only possible way is to drop and re-create the view. But that is no problem, you can easily get the view definition...
Read more >
Internal Server Error when updating a Sales or Support ...
Select a Record type 3. Click on Edit 4. Change the Sales process. Result: "Error: Duplicate Developer Name". Workaround 1. Change name of ......
Read more >
ERROR: cannot alter type of a column used in a trigger definition
This is the situation: I've a table with a column of type "geometry" which is used in a trigger. There is no constraint...
Read more >
Azure Event Hubs - Resource Manager exceptions
Error code Error subcode Error message BadRequest 40000 PartitionCount can't be changed for an event hub. BadRequest none The specified name isn't available. BadRequest none Can't...
Read more >
How to Fix the 500 Internal Server Error in WordPress
Do you have the HTTP 500 internal server error in WordPress? Step by step troubleshooting guide on how to fix the internal server...
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